#!/usr/bin/env python3 # This Source Code Form is subject to the terms of the # Mozilla Public License, v. 2.0. # If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/. import requests from mastodon import Mastodon import json client = Mastodon( client_id=cfg['client']['id'], client_secret = cfg['client']['secret'], access_token=cfg['secret'], api_base_url=cfg['site']) kind = 'general' if kind == 'images': r = requests.get("https://searx.lynnesbian.space/?category_images=1&q={}&format=json".format(q)) else: r = requests.get("https://searx.lynnesbian.space/?q={}&format=json".format(q)) j = r.json() if kind == 'images': text = "Here's what I found by searching for images with the query \"{}\".".format(q) else: result = j['results'][0] text = result['title'] + "\n" + result['url'] + "\n" + result['content'] + "\n" + "(Score: {})".format(result['score']) print(text)