<commit_before>"""
xkcd module by @Protoh
"""
import logging
import telegram
from telegram import Bot, Update
from telegram.ext import MessageHandler, Updater, Filters
from urllib.parse import quote
import requests, json
import constants # pylint: disable=E0401
LOGGER = logging.getLogger("xkcd module")

def preload(updater: Updater, level):
    """
    This loads whenever plugin starts
    Even if you dont need it, you SHOULD put at least
    return None, otherwise your plugin wont load
    """
    return None, constants.NOTHING

def xkcd(bot: Bot, update: Update, user, args): # pylint: disable=W0613
    """/xkcd command"""
    msg = update.message
    argument = msg.text.lstrip('/xkcd')
    argument = argument.strip()
    id = ""
    if not argument:
        id = -1
    else:
        if argument.isdigit():
            id = argument
        else:
            queryresult = requests.get('https://relevantxkcd.appspot.com/process?',params={"action":"xkcd","query":quote("gft")}).text
            id = queryresult.split(" ")[2].lstrip("\n")
    data = ""
    if id == -1:
        data = json.loads(requests.get("https://xkcd.com/info.0.json").text)
    else:
        try:
            data = json.loads(requests.get("https://xkcd.com/{}/info.0.json".format(id)).text)
        except json.JSONDecodeError:
            msg.reply_text("xkcd n.{} not found!".format(id))
            return None, constants.NOTHING
    msg.reply_photo(photo = data['img'])
    data['month'] = data['month'].zfill(2)
    data['day'] = data['day'].zfill(2)
    msg.reply_text("*title:* %(safe_title)s\n*number:* %(num)s\n*date*`(yyyy-mm-dd for christ's sake)`*:* %(year)s-%(month)s-%(day)s\n*alt:* _%(alt)s_\n*link:* xkcd.com/%(num)s" % data,disable_web_page_preview=True, parse_mode=telegram.ParseMode.MARKDOWN)
    return None, constants.NOTHING
COMMANDS = [
    {
        "command":"/xkcd",
        "function":xkcd,
        "description":"Sends xkcd comics in the chat!",
        "inline_support":True
    }
]<commit_msg>Fixed documentation<commit_after>"""
xkcd module by @Protoh
"""
import logging
import telegram
from telegram import Bot, Update
from telegram.ext import MessageHandler, Updater, Filters
from urllib.parse import quote
import requests, json
import constants # pylint: disable=E0401
LOGGER = logging.getLogger("xkcd module")

def preload(updater: Updater, level):
    """
    This loads whenever plugin starts
    Even if you dont need it, you SHOULD put at least
    return None, otherwise your plugin wont load
    """
    return None, constants.NOTHING

def xkcd(bot: Bot, update: Update, user, args): # pylint: disable=W0613
    """/xkcd command"""
    msg = update.message
    argument = msg.text.lstrip('/xkcd')
    argument = argument.strip()
    id = ""
    if not argument:
        id = -1
    else:
        if argument.isdigit():
            id = argument
        else:
            queryresult = requests.get('https://relevantxkcd.appspot.com/process?',params={"action":"xkcd","query":quote("gft")}).text
            id = queryresult.split(" ")[2].lstrip("\n")
    data = ""
    if id == -1:
        data = json.loads(requests.get("https://xkcd.com/info.0.json").text)
    else:
        try:
            data = json.loads(requests.get("https://xkcd.com/{}/info.0.json".format(id)).text)
        except json.JSONDecodeError:
            msg.reply_text("xkcd n.{} not found!".format(id))
            return None, constants.NOTHING
    msg.reply_photo(photo = data['img'])
    data['month'] = data['month'].zfill(2)
    data['day'] = data['day'].zfill(2)
    msg.reply_text("*title:* %(safe_title)s\n*number:* %(num)s\n*date*`(yyyy-mm-dd for christ's sake)`*:* %(year)s-%(month)s-%(day)s\n*alt:* _%(alt)s_\n*link:* xkcd.com/%(num)s" % data,disable_web_page_preview=True, parse_mode=telegram.ParseMode.MARKDOWN)
    return None, constants.NOTHING
COMMANDS = [
    {
        "command":"/xkcd",
        "function":xkcd,
        "description":"Sends xkcd comics in the chat! usage: '/xkcd', '/xkcd <number>', or '/xkcd <query>'",
        "inline_support":True
    }
]
{'fraction_non_alphanumeric': 0.16098159509202453, 'fraction_numerical': 0.007361963190184049, 'mean_word_length': 3.133874239350913, 'pattern_counts': {'":': 12, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5726151', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1373, 'n_words': 302}