Exemplo n.º 1
0
                reply = song.format()
            else:
                reply = "Couldn't find any lyrics for that song!"
        else:
            reply = "Song not found!"
        if len(reply) > 4090:
            with open("lyrics.txt", 'w') as f:
                f.write(f"{reply}\n\n\nOwO UwU OmO")
            with open("lyrics.txt", 'rb') as f:
                msg.reply_document(
                    document=f,
                    caption=
                    "Message length exceeded max limit! Sending as a text file."
                )
        else:
            msg.reply_text(reply)


__help__ = """
Want to get the lyrics of your favorite songs straight from the app? This module is perfect for that!
*Available commands:*
 - /lyrics <song>: returns the lyrics of that song.
 You can either enter just the song name or both the artist and song name.
"""

__mod_name__ = "Lyrics"

LYRICS_HANDLER = DisableAbleCommandHandler("lyrics", lyrics, pass_args=True)

dispatcher.add_handler(LYRICS_HANDLER)
Exemplo n.º 2
0
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text(f"Muted for {time_val}!", quote=False)
            return log
        else:
            LOGGER.warning(update)
            LOGGER.exception("ERROR muting user %s in chat %s (%s) due to %s", user_id, chat.title, chat.id,
                             excp.message)
            message.reply_text("Well damn, I can't mute that user.")

    return ""


__help__ = """
*Admin only:*
 - /mute <userhandle>: silences a user. Can also be used as a reply, muting the replied to user.
 - /tmute <userhandle> x(m/h/d): mutes a user for x time. (via handle, or reply). m = minutes, h = hours, d = days.
 - /unmute <userhandle>: unmutes a user. Can also be used as a reply, muting the replied to user.
"""

MUTE_HANDLER = CommandHandler("mute", mute, pass_args=True)
UNMUTE_HANDLER = CommandHandler("unmute", unmute, pass_args=True)
TEMPMUTE_HANDLER = CommandHandler(["tmute", "tempmute"], temp_mute, pass_args=True)

dispatcher.add_handler(MUTE_HANDLER)
dispatcher.add_handler(UNMUTE_HANDLER)
dispatcher.add_handler(TEMPMUTE_HANDLER)

__mod_name__ = "Muting"
__handlers__ = [MUTE_HANDLER, UNMUTE_HANDLER, TEMPMUTE_HANDLER]
Exemplo n.º 3
0

@run_async
def tts(bot: Bot, update: Update, args):
    current_time = datetime.strftime(datetime.now(), "%d.%m.%Y %H:%M:%S")
    filename = datetime.now().strftime("%d%m%y-%H%M%S%f")
    reply = " ".join(args)
    update.message.chat.send_action(ChatAction.RECORD_AUDIO)
    lang="ml"
    tts = gTTS(reply, lang)
    tts.save("k.mp3")
    with open("k.mp3", "rb") as f:
        linelist = list(f)
        linecount = len(linelist)
    if linecount == 1:
        update.message.chat.send_action(ChatAction.RECORD_AUDIO)
        lang = "en"
        tts = gTTS(reply, lang)
        tts.save("k.mp3")
    with open("k.mp3", "rb") as speech:
        update.message.reply_voice(speech, quote=False)

__help__ = """
 - /tts <sentence>:  Text to Speech!
"""

__mod_name__ = "Text-to-Speech"

TTS_HANDLER = DisableAbleCommandHandler('tts', tts, pass_args=True)
dispatcher.add_handler(TTS_HANDLER)
Exemplo n.º 4
0
                                             pass_args=True)
REMOVE_CLEAN_BLUE_TEXT_HANDLER = CommandHandler("unignorecleanbluetext",
                                                remove_bluetext_ignore,
                                                pass_args=True)
ADD_CLEAN_BLUE_TEXT_GLOBAL_HANDLER = CommandHandler(
    "ignoreglobalcleanbluetext", add_bluetext_ignore_global, pass_args=True)
REMOVE_CLEAN_BLUE_TEXT_GLOBAL_HANDLER = CommandHandler(
    "unignoreglobalcleanbluetext",
    remove_bluetext_ignore_global,
    pass_args=True)
LIST_CLEAN_BLUE_TEXT_HANDLER = CommandHandler("listcleanbluetext",
                                              bluetext_ignore_list)
CLEAN_BLUE_TEXT_HANDLER = MessageHandler(Filters.command & Filters.group,
                                         clean_blue_text_must_click)

dispatcher.add_handler(SET_CLEAN_BLUE_TEXT_HANDLER)
dispatcher.add_handler(ADD_CLEAN_BLUE_TEXT_HANDLER)
dispatcher.add_handler(REMOVE_CLEAN_BLUE_TEXT_HANDLER)
dispatcher.add_handler(ADD_CLEAN_BLUE_TEXT_GLOBAL_HANDLER)
dispatcher.add_handler(REMOVE_CLEAN_BLUE_TEXT_GLOBAL_HANDLER)
dispatcher.add_handler(LIST_CLEAN_BLUE_TEXT_HANDLER)
dispatcher.add_handler(CLEAN_BLUE_TEXT_HANDLER, BLUE_TEXT_CLEAN_GROUP)

__mod_name__ = "Bluetext Cleaning"
__handlers__ = [
    SET_CLEAN_BLUE_TEXT_HANDLER, ADD_CLEAN_BLUE_TEXT_HANDLER,
    REMOVE_CLEAN_BLUE_TEXT_HANDLER, ADD_CLEAN_BLUE_TEXT_GLOBAL_HANDLER,
    REMOVE_CLEAN_BLUE_TEXT_GLOBAL_HANDLER, LIST_CLEAN_BLUE_TEXT_HANDLER,
    (CLEAN_BLUE_TEXT_HANDLER, BLUE_TEXT_CLEAN_GROUP)
]
Exemplo n.º 5
0
 - /user <user>: returns information about a MyAnimeList user.
 - /upcoming: returns a list of new anime in the upcoming seasons.
 - /kaizoku <anime>: search an anime on animekaizoku.com
 - /kayo <anime>: search an anime on animekayo.com
 """

ANIME_HANDLER = DisableAbleCommandHandler("anime", anime)
CHARACTER_HANDLER = DisableAbleCommandHandler("character", character)
MANGA_HANDLER = DisableAbleCommandHandler("manga", manga)
USER_HANDLER = DisableAbleCommandHandler("user", user)
UPCOMING_HANDLER = DisableAbleCommandHandler("upcoming", upcoming)
KAIZOKU_SEARCH_HANDLER = DisableAbleCommandHandler("kaizoku", kaizoku)
KAYO_SEARCH_HANDLER = DisableAbleCommandHandler("kayo", kayo)
BUTTON_HANDLER = CallbackQueryHandler(button, pattern='anime_.*')

dispatcher.add_handler(BUTTON_HANDLER)
dispatcher.add_handler(ANIME_HANDLER)
dispatcher.add_handler(CHARACTER_HANDLER)
dispatcher.add_handler(MANGA_HANDLER)
dispatcher.add_handler(USER_HANDLER)
dispatcher.add_handler(KAIZOKU_SEARCH_HANDLER)
dispatcher.add_handler(KAYO_SEARCH_HANDLER)
dispatcher.add_handler(UPCOMING_HANDLER)

__mod_name__ = "MyAnimeList"
__command_list__ = [
    "anime", "manga", "character", "user", "upcoming", "kaizoku", "kayo"
]
__handlers__ = [
    ANIME_HANDLER, CHARACTER_HANDLER, MANGA_HANDLER, USER_HANDLER,
    UPCOMING_HANDLER, KAIZOKU_SEARCH_HANDLER, KAYO_SEARCH_HANDLER,
Exemplo n.º 6
0
@run_async
def shellExecute(bot: Bot, update: Update):
    cmd = update.message.text.split(' ', maxsplit=1)
    if len(cmd) == 1:
        sendMessage("No command provided!", bot, update)
        return
    LOGGER.info(cmd)
    output = shell(cmd[1])
    if output[1].decode():
        LOGGER.error(f"Shell: {output[1].decode()}")
    if len(output[0].decode()) > 4000:
        with open("shell.txt", 'w') as f:
            f.write(f"Output\n-----------\n{output[0].decode()}\n")
            if output[1]:
                f.write(f"STDError\n-----------\n{output[1].decode()}\n")
        with open("shell.txt", 'rb') as f:
            bot.send_document(document=f,
                              filename=f.name,
                              reply_to_message_id=update.message.message_id,
                              chat_id=update.message.chat_id)
    else:
        if output[1].decode():
            sendMessage(f"<code>{output[1].decode()}</code>", bot, update)
            return
        else:
            sendMessage(f"<code>{output[0].decode()}</code>", bot, update)


shell_handler = CommandHandler(('sh', 'shell'), shellExecute)
dispatcher.add_handler(shell_handler)
Exemplo n.º 7
0
 - /lock <type>: lock items of a certain type (not available in private)
 - /unlock <type>: unlock items of a certain type (not available in private)
 - /locks: the current list of locks in this chat.

Locks can be used to restrict a group's users.
eg:
Locking urls will auto-delete all messages with urls which haven't been whitelisted, locking stickers will delete all \
stickers, etc.
Locking bots will stop non-admins from adding bots to the chat.
"""

LOCKTYPES_HANDLER = DisableAbleCommandHandler("locktypes", locktypes)
LOCK_HANDLER = CommandHandler("lock", lock, pass_args=True)
UNLOCK_HANDLER = CommandHandler("unlock", unlock, pass_args=True)
LOCKED_HANDLER = CommandHandler("locks", list_locks)
LOCKABLE_HANDLER = MessageHandler(Filters.all & Filters.group, del_lockables)
RESTRICTION_HANDLER = MessageHandler(Filters.all & Filters.group, rest_handler)

dispatcher.add_handler(LOCK_HANDLER)
dispatcher.add_handler(UNLOCK_HANDLER)
dispatcher.add_handler(LOCKTYPES_HANDLER)
dispatcher.add_handler(LOCKED_HANDLER)
dispatcher.add_handler(LOCKABLE_HANDLER, PERM_GROUP)
dispatcher.add_handler(RESTRICTION_HANDLER, REST_GROUP)

__mod_name__ = "Locks"
__handlers__ = [
    LOCKTYPES_HANDLER, LOCK_HANDLER, UNLOCK_HANDLER, LOCKED_HANDLER,
    (LOCKABLE_HANDLER, PERM_GROUP), (RESTRICTION_HANDLER, REST_GROUP)
]
Exemplo n.º 8
0
    __help__ = """
*Admin only:*
- /logchannel: get log channel info
- /setlog: set the log channel.
- /unsetlog: unset the log channel.

Setting the log channel is done by:
- adding the bot to the desired channel (as an admin!)
- sending /setlog in the channel
- forwarding the /setlog to the group
"""

    __mod_name__ = "Log Channels"

    LOG_HANDLER = CommandHandler("logchannel", logging)
    SET_LOG_HANDLER = CommandHandler("setlog", setlog)
    UNSET_LOG_HANDLER = CommandHandler("unsetlog", unsetlog)

    dispatcher.add_handler(LOG_HANDLER)
    dispatcher.add_handler(SET_LOG_HANDLER)
    dispatcher.add_handler(UNSET_LOG_HANDLER)

else:
    # run anyway if module not loaded
    def loggable(func):
        return func

    def gloggable(func):
        return func
Exemplo n.º 9
0
    unload_messasge.edit_text(f"Successfully unloaded module : <b>{text}</b>",
                              parse_mode=ParseMode.HTML)


@run_async
@sudo_plus
def listmodules(bot: Bot, update: Update):
    message = update.effective_message
    module_list = []

    for helpable_module in HELPABLE:
        helpable_module_info = IMPORTED[helpable_module]
        file_info = IMPORTED[helpable_module_info.__mod_name__.lower()]
        file_name = file_info.__name__.rsplit("keiko.modules.", 1)[1]
        mod_name = file_info.__mod_name__
        module_list.append(f'- <code>{mod_name} ({file_name})</code>\n')
    module_list = "Following modules are loaded : \n\n" + ''.join(module_list)
    message.reply_text(module_list, parse_mode=ParseMode.HTML)


LOAD_HANDLER = CommandHandler("load", load)
UNLOAD_HANDLER = CommandHandler("unload", unload)
LISTMODULES_HANDLER = CommandHandler("listmodules", listmodules)

dispatcher.add_handler(LOAD_HANDLER)
dispatcher.add_handler(UNLOAD_HANDLER)
dispatcher.add_handler(LISTMODULES_HANDLER)

__mod_name__ = "Modules"
Exemplo n.º 10
0
    "ヽ(>∀<☆)ノ", "\( ̄▽ ̄)/", "(o˘◡˘o)", "(╯✧▽✧)╯", "( ‾́ ◡ ‾́ )", "(๑˘︶˘๑)",
    "(´・ᴗ・ ` )", "( ͡° ʖ̯ ͡°)", "( ఠ ͟ʖ ఠ)", "( ಥ ʖ̯ ಥ)", "(≖ ͜ʖ≖)", "ヘ( ̄ω ̄ヘ)",
    "(ノ≧∀≦)ノ", "└( ̄- ̄└))", "┌(^^)┘", "(^_^♪)", "(〜 ̄△ ̄)〜", "(「• ω •)「",
    "( ˘ ɜ˘) ♬♪♫", "( o˘◡˘o) ┌iii┐", "♨o(>_<)o♨", "( ・・)つ―{}@{}@{}-",
    "(*´з`)口゚。゚口(・∀・ )", "( *^^)o∀*∀o(^^* )", "-●●●-c(・・ )", "(ノ≧∀≦)ノ ‥…━━━★",
    "╰( ͡° ͜ʖ ͡° )つ──☆*:・゚", "(∩ᄑ_ᄑ)⊃━☆゚*・。*・:≡( ε:)"
]


@run_async
def react(bot: Bot, update: Update):
    message = update.effective_message
    react = random.choice(reactions)
    if message.reply_to_message:
        message.reply_to_message.reply_text(react)
    else:
        message.reply_text(react)


__help__ = """
 - /react: Reacts with a random reaction
"""

REACT_HANDLER = DisableAbleCommandHandler("react", react)

dispatcher.add_handler(REACT_HANDLER)

__mod_name__ = "React"
__command_list__ = ["react"]
__handlers__ = [REACT_HANDLER]
Exemplo n.º 11
0
    upt_header = "".join(b)
    f = int(uptime())
    pcuptime = seconds_to_str(f)
    up = "{}\n\nUptime: {}\n".format(upt_header, pcuptime)
    c = "=" * 15, " CPU ", "=" * 15
    cpu_header = "".join(c)
    cpumodel = cpuinfo.get_cpu_info()['brand']
    cpufreq = psutil.cpu_freq()
    cpu_info = "{}\n\n{}\nPhysical cores: {}\nTotal cores: {}\nMax Frequency: {:.2f} Mhz\nCurrent Frequency: {:.2f} Mhz\nCPU Usage: {}%\n".format(
        cpu_header, cpumodel, psutil.cpu_count(logical=False),
        psutil.cpu_count(logical=True), cpufreq.max, cpufreq.current,
        psutil.cpu_percent(percpu=False, interval=1))
    d = "=" * 15, " RAM ", "=" * 15
    ram_header = "".join(d)
    svmem = psutil.virtual_memory()
    ram_info = "{}\n\nTotal: {}\nAvailable: {} ({:.2f}%)\nUsed: {} ({:.2f}%)\n".format(
        ram_header, get_size(svmem.total), get_size(svmem.available),
        100 - svmem.percent, get_size(svmem.used), svmem.percent)
    server_status = "```\n{}\n{}\n{}\n{}\n```".format(sys_info, up, cpu_info,
                                                      ram_info)
    update.message.reply_text(server_status, parse_mode="Markdown")


__help__ = """
 **Dev Only!**
 - /sysinfo - Gives information about bot hosted server.
"""
__mod_name__ = "System Info"
SYSINFO_HANDLER = DisableAbleCommandHandler("sysinfo", sysinfo)
dispatcher.add_handler(SYSINFO_HANDLER)
Exemplo n.º 12
0
 - /invitelink: gets invitelink
 - /promote: promotes the user replied to
 - /demote: demotes the user replied to
 - /settitle: sets a custom title for an admin that the bot promoted
"""

ADMINLIST_HANDLER = DisableAbleCommandHandler(["adminlist", "admins"], adminlist)

PIN_HANDLER = CommandHandler("pin", pin, pass_args=True, filters=Filters.group)
UNPIN_HANDLER = CommandHandler("unpin", unpin, filters=Filters.group)

INVITE_HANDLER = DisableAbleCommandHandler("invitelink", invite, filters=Filters.group)

PROMOTE_HANDLER = CommandHandler("promote", promote, pass_args=True)
DEMOTE_HANDLER = CommandHandler("demote", demote, pass_args=True)

SET_TITLE_HANDLER = CommandHandler("settitle", set_title, pass_args=True)

dispatcher.add_handler(ADMINLIST_HANDLER)
dispatcher.add_handler(PIN_HANDLER)
dispatcher.add_handler(UNPIN_HANDLER)
dispatcher.add_handler(INVITE_HANDLER)
dispatcher.add_handler(PROMOTE_HANDLER)
dispatcher.add_handler(DEMOTE_HANDLER)
dispatcher.add_handler(SET_TITLE_HANDLER)

__mod_name__ = "Admin"
__command_list__ = ["adminlist", "admins", "invitelink"]
__handlers__ = [ADMINLIST_HANDLER, PIN_HANDLER, UNPIN_HANDLER,
                INVITE_HANDLER, PROMOTE_HANDLER, DEMOTE_HANDLER, SET_TITLE_HANDLER]
Exemplo n.º 13
0
__help__ = """
Chatbot utilizes the CoffeeHouse API and allows Kēiko to talk back making your chat more interactive.
This is an ongoing upgrade and is only available in your chats if you reach out to the [Support Group](https://t.me/KeikoSupport) and ask for it.
In future we might make it open for any chat and controllable by group admins.
Powered by [CoffeeHouse](https://coffeehouse.intellivoid.net/) from @Intellivoid
Commands: These only work for Keiko Staff users.
 - /addchat : Enables Chatbot mode in the chat.
 - /rmchat  : Disables Chatbot mode in the chat.
*Nation Level Required:*
 - /listai :  Lists the chats the chatmode is enabled in.
"""

ADD_CHAT_HANDLER = CommandHandler("addchat",
                                  add_chat,
                                  filters=CustomFilters.dev_filter)
REMOVE_CHAT_HANDLER = CommandHandler("rmchat",
                                     remove_chat,
                                     filters=CustomFilters.dev_filter)
CHATBOT_HANDLER = MessageHandler(
    Filters.text & (~Filters.regex(r"^#[^\s]+") & ~Filters.regex(r"^!")
                    & ~Filters.regex(r"^s\/")), chatbot)
# Filters for ignoring #note messages, !commands and sed.
CHATBOTLIST_HANDLER = CommandHandler("listai",
                                     list_chatbot,
                                     filters=CustomFilters.dev_filter)

dispatcher.add_handler(ADD_CHAT_HANDLER)
dispatcher.add_handler(REMOVE_CHAT_HANDLER)
dispatcher.add_handler(CHATBOT_HANDLER)
dispatcher.add_handler(CHATBOTLIST_HANDLER)
Exemplo n.º 14
0
    chatfile = 'List of chats.\n'
    for chat in all_chats:
        chatfile += f"{chat.chat_name} - ({chat.chat_id})\n"

    with BytesIO(str.encode(chatfile)) as output:
        output.name = "chatlist.txt"
        update.effective_message.reply_document(document=output, filename="chatlist.txt",
                                                caption="Here is the list of chats in my Hit List.")


def __stats__():
    return f"{sql.num_users()} users, across {sql.num_chats()} chats"


def __migrate__(old_chat_id, new_chat_id):
    sql.migrate_chat(old_chat_id, new_chat_id)


__help__ = ""  # no help string

BROADCAST_HANDLER = CommandHandler("broadcast", broadcast)
USER_HANDLER = MessageHandler(Filters.all & Filters.group, log_user)
CHATLIST_HANDLER = CommandHandler("chatlist", chats)

dispatcher.add_handler(USER_HANDLER, USERS_GROUP)
dispatcher.add_handler(BROADCAST_HANDLER)
dispatcher.add_handler(CHATLIST_HANDLER)

__mod_name__ = "Users"
__handlers__ = [(USER_HANDLER, USERS_GROUP), BROADCAST_HANDLER, CHATLIST_HANDLER]
Exemplo n.º 15
0
__help__ = """
 - /id: get the current group id. If used by replying to a message, gets that user's id.
 - /gifid: reply to a gif to me to tell you its file ID.
 - /info: get information about a user.
 - /markdownhelp: quick summary of how markdown works in telegram - can only be called in private chats.
"""

ID_HANDLER = DisableAbleCommandHandler("id", get_id, pass_args=True)
GIFID_HANDLER = DisableAbleCommandHandler("gifid", gifid)
INFO_HANDLER = DisableAbleCommandHandler("info", info, pass_args=True)
ECHO_HANDLER = DisableAbleCommandHandler("echo", echo, filters=Filters.group)
MD_HELP_HANDLER = CommandHandler("markdownhelp",
                                 markdown_help,
                                 filters=Filters.private)
STATS_HANDLER = CommandHandler("stats", stats)

dispatcher.add_handler(ID_HANDLER)
dispatcher.add_handler(GIFID_HANDLER)
dispatcher.add_handler(INFO_HANDLER)
dispatcher.add_handler(ECHO_HANDLER)
dispatcher.add_handler(MD_HELP_HANDLER)
dispatcher.add_handler(STATS_HANDLER)

__mod_name__ = "Misc"
__command_list__ = ["id", "info", "echo"]
__handlers__ = [
    ID_HANDLER, GIFID_HANDLER, INFO_HANDLER, ECHO_HANDLER, MD_HELP_HANDLER,
    STATS_HANDLER
]
Exemplo n.º 16
0
def load(bot: Bot, update: Update):
    message = update.effective_message
    text = message.text.split(" ", 1)[1]
    load_messasge = message.reply_text(
        f"Attempting to load module : <b>{text}</b>",
        parse_mode=ParseMode.HTML)

    try:
        imported_module = importlib.import_module("keiko.modules." + text)
    except:
        load_messasge.edit_text("Does that module even exist?")
        return

    if not hasattr(imported_module, "__mod_name__"):
        imported_module.__mod_name__ = imported_module.__name__

    if not imported_module.__mod_name__.lower() in IMPORTED:
        IMPORTED[imported_module.__mod_name__.lower()] = imported_module
    else:
        load_messasge.edit_text("Module already loaded.")
        return
    if "__handlers__" in dir(imported_module):
        handlers = imported_module.__handlers__
        for handler in handlers:
            if type(handler) != tuple:
                dispatcher.add_handler(handler)
            else:
                handler_name, priority = handler
                dispatcher.add_handler(handler_name, priority)
    else:
        IMPORTED.pop(imported_module.__mod_name__.lower())
        load_messasge.edit_text("The module cannot be loaded.")
        return

    if hasattr(imported_module, "__help__") and imported_module.__help__:
        HELPABLE[imported_module.__mod_name__.lower()] = imported_module

    # Chats to migrate on chat_migrated events
    if hasattr(imported_module, "__migrate__"):
        MIGRATEABLE.append(imported_module)

    if hasattr(imported_module, "__stats__"):
        STATS.append(imported_module)

    if hasattr(imported_module, "__user_info__"):
        USER_INFO.append(imported_module)

    if hasattr(imported_module, "__import_data__"):
        DATA_IMPORT.append(imported_module)

    if hasattr(imported_module, "__export_data__"):
        DATA_EXPORT.append(imported_module)

    if hasattr(imported_module, "__chat_settings__"):
        CHAT_SETTINGS[imported_module.__mod_name__.lower()] = imported_module

    if hasattr(imported_module, "__user_settings__"):
        USER_SETTINGS[imported_module.__mod_name__.lower()] = imported_module

    load_messasge.edit_text(
        "Successfully loaded module : <b>{}</b>".format(text),
        parse_mode=ParseMode.HTML)
Exemplo n.º 17
0
from keiko import dispatcher
from keiko.modules.disable import DisableAbleCommandHandler


@run_async
def covid(bot: Bot, update: Update):
    message = update.effective_message
    text = message.text.split(' ', 1)
    if len(text) == 1:
        r = requests.get(f"https://corona.lmao.ninja/v2/all").json()
        reply_text = f"**Global Totals** ­Ъда\nCases: {r['cases']:,}\nCases Today: {r['todayCases']:,}\nDeaths: {r['deaths']:,}\nDeaths Today: {r['todayDeaths']:,}\nRecovered: {r['recovered']:,}\nActive: {r['active']:,}\nCritical: {r['critical']:,}\nCases/Mil: {r['casesPerOneMillion']}\nDeaths/Mil: {r['deathsPerOneMillion']}"
    else:
        variabla = text[1]
        r = requests.get(
            f"https://corona.lmao.ninja/v2/countries/{variabla}").json()
        reply_text = f"**Cases for {r['country']} ­Ъда**\nCases: {r['cases']:,}\nCases Today: {r['todayCases']:,}\nDeaths: {r['deaths']:,}\nDeaths Today: {r['todayDeaths']:,}\nRecovered: {r['recovered']:,}\nActive: {r['active']:,}\nCritical: {r['critical']:,}\nCases/Mil: {r['casesPerOneMillion']}\nDeaths/Mil: {r['deathsPerOneMillion']}"
    message.reply_text(reply_text, parse_mode=ParseMode.MARKDOWN)


__help__ = """
 - /covid To get Global data
 - /covid <country> To get data of a country
"""

COVID_HANDLER = DisableAbleCommandHandler(["covid", "corona"], covid)

dispatcher.add_handler(COVID_HANDLER)

__mod_name__ = "Corona Info"
Exemplo n.º 18
0
        return
    name = bot.get_chat(user).first_name
    text = f"<b>Common chats with {name}</b>\n"
    for chat in common_list:
        try:
            chat_name = bot.get_chat(chat).title
            sleep(0.3)
            text += f"• <code>{chat_name}</code>\n"
        except BadRequest:
            pass
        except Unauthorized:
            pass
        except RetryAfter as e:
            sleep(e.retry_after)

    if len(text) < 4096:
        msg.reply_text(text, parse_mode="HTML")
    else:
        with open("common_chats.txt", 'w') as f:
            f.write(text)
        with open("common_chats.txt", 'rb') as f:
            msg.reply_document(f)
        os.remove("common_chats.txt")


COMMON_CHATS_HANDLER = CommandHandler("getchats",
                                      get_user_common_chats,
                                      filters=Filters.user(OWNER_ID),
                                      pass_args=True)
dispatcher.add_handler(COMMON_CHATS_HANDLER)
Exemplo n.º 19
0
    def __migrate__(old_chat_id, new_chat_id):
        sql.migrate_chat(old_chat_id, new_chat_id)


    def __chat_settings__(chat_id, user_id):
        return build_curr_disabled(chat_id)


    DISABLE_HANDLER = CommandHandler("disable", disable, pass_args=True)
    DISABLE_MODULE_HANDLER = CommandHandler("disablemodule", disable_module, pass_args=True)
    ENABLE_HANDLER = CommandHandler("enable", enable, pass_args=True)
    ENABLE_MODULE_HANDLER = CommandHandler("enablemodule", enable_module, pass_args=True)
    COMMANDS_HANDLER = CommandHandler(["cmds", "disabled"], commands)
    TOGGLE_HANDLER = CommandHandler("listcmds", list_cmds)

    dispatcher.add_handler(DISABLE_HANDLER)
    dispatcher.add_handler(DISABLE_MODULE_HANDLER)
    dispatcher.add_handler(ENABLE_HANDLER)
    dispatcher.add_handler(ENABLE_MODULE_HANDLER)
    dispatcher.add_handler(COMMANDS_HANDLER)
    dispatcher.add_handler(TOGGLE_HANDLER)

    __help__ = """
    - /cmds: check the current status of disabled commands

    *Admin only:*
    - /enable <cmd name>: enable that command
    - /disable <cmd name>: disable that command
    - /enablemodule <module name>: enable all commands in that module
    - /disablemodule <module name>: disable all commands in that module
    - /listcmds: list all possible toggleable commands
Exemplo n.º 20
0
                                                    url=f"t.me/{bot.username}")
                           ]]))
        return

    if success:
        msg.reply_text(
            f"Sticker pack successfully created. Get it [here](t.me/addstickers/{packname})",
            parse_mode=ParseMode.MARKDOWN)
    else:
        msg.reply_text(
            "Failed to create sticker pack. Possibly due to blek mejik.")


__help__ = """
- /stickerid: reply to a sticker to me to tell you its file ID.
- /getsticker: reply to a sticker to me to upload its raw PNG file.
- /kang: reply to a sticker to add it to your pack.
"""

__mod_name__ = "Stickers"
STICKERID_HANDLER = DisableAbleCommandHandler("stickerid", stickerid)
GETSTICKER_HANDLER = DisableAbleCommandHandler("getsticker", getsticker)
KANG_HANDLER = DisableAbleCommandHandler("kang",
                                         kang,
                                         pass_args=True,
                                         admin_ok=True)

dispatcher.add_handler(STICKERID_HANDLER)
dispatcher.add_handler(GETSTICKER_HANDLER)
dispatcher.add_handler(KANG_HANDLER)
Exemplo n.º 21
0
        f"Finding timezone info for <b>{query}</b>", parse_mode=ParseMode.HTML)

    query_timezone = query.lower()
    if len(query_timezone) == 2:
        result = generate_time(query_timezone, ["countryCode"])
    else:
        result = generate_time(query_timezone, ["zoneName", "countryName"])

    if not result:
        send_message.edit_text(
            f"Timezone info not available for <b>{query}</b>",
            parse_mode=ParseMode.HTML)
        return

    send_message.edit_text(result, parse_mode=ParseMode.HTML)


__help__ = """
 - /time <query> : Gives information about a timezone.

Available queries : Country Code/Country Name/Timezone Name
"""

TIME_HANDLER = DisableAbleCommandHandler("time", gettime)

dispatcher.add_handler(TIME_HANDLER)

__mod_name__ = "Time"
__command_list__ = ["time"]
__handlers__ = [TIME_HANDLER]
Exemplo n.º 22
0
"""

__mod_name__ = "Memes and etc."

OWO_HANDLER = DisableAbleCommandHandler("owo", owo, admin_ok=True)
STRETCH_HANDLER = DisableAbleCommandHandler("stretch", stretch)
VAPOR_HANDLER = DisableAbleCommandHandler("vapor",
                                          vapor,
                                          pass_args=True,
                                          admin_ok=True)
ZALGO_HANDLER = DisableAbleCommandHandler("zalgofy", zalgotext)
DEEPFRY_HANDLER = DisableAbleCommandHandler("deepfry",
                                            deepfryer,
                                            admin_ok=True)
SHOUT_HANDLER = DisableAbleCommandHandler("shout", shout, pass_args=True)
KAN_HANDLER = DisableAbleCommandHandler("kan", kan)
CHANGEMYMIND_HANDLER = DisableAbleCommandHandler("changemymind", changemymind)
TRUMPTWEET_HANDLER = DisableAbleCommandHandler("trumptweet", trumptweet)
EIGHTBALL_HANDLER = DisableAbleCommandHandler("eightball", eightball)

dispatcher.add_handler(SHOUT_HANDLER)
dispatcher.add_handler(OWO_HANDLER)
dispatcher.add_handler(STRETCH_HANDLER)
dispatcher.add_handler(VAPOR_HANDLER)
dispatcher.add_handler(ZALGO_HANDLER)
dispatcher.add_handler(DEEPFRY_HANDLER)
dispatcher.add_handler(KAN_HANDLER)
dispatcher.add_handler(CHANGEMYMIND_HANDLER)
dispatcher.add_handler(TRUMPTWEET_HANDLER)
dispatcher.add_handler(EIGHTBALL_HANDLER)
Exemplo n.º 23
0
                "Do you even sed? Apparently not.")
            return

        # empty string errors -_-
        if len(text) >= telegram.MAX_MESSAGE_LENGTH:
            update.effective_message.reply_text(
                "The result of the sed command was too long for \
                                                 telegram!")
        elif text:
            update.effective_message.reply_to_message.reply_text(text)


__help__ = """
 - s/<text1>/<text2>(/<flag>): Reply to a message with this to perform a sed operation on that message, replacing all \
occurrences of 'text1' with 'text2'. Flags are optional, and currently include 'i' for ignore case, 'g' for global, \
or nothing. Delimiters include `/`, `_`, `|`, and `:`. Text grouping is supported. The resulting message cannot be \
larger than {}.
*Reminder:* Sed uses some special characters to make matching easier, such as these: `+*.?\\`
If you want to use these characters, make sure you escape them!
eg: \\?.
""".format(telegram.MAX_MESSAGE_LENGTH)

__mod_name__ = "Sed/Regex"

SED_HANDLER = DisableAbleRegexHandler(r's([{}]).*?\1.*'.format(
    "".join(DELIMITERS)),
                                      sed,
                                      friendly="sed")

dispatcher.add_handler(SED_HANDLER)
Exemplo n.º 24
0

__help__ = """
*Admin only:*
 - /gbanstat <on/off/yes/no>: Will disable the effect of global bans on your group, or return your current settings.

Gbans, also known as global bans, are used by the bot owners to ban spammers across all groups. This helps protect \
you and your groups by removing spam flooders as quickly as possible.\
Note: You can appeal gbans or ask gbans at @Aman_Ahmed
"""

GBAN_HANDLER = CommandHandler("gban", gban, pass_args=True)
UNGBAN_HANDLER = CommandHandler("ungban", ungban, pass_args=True)
GBAN_LIST = CommandHandler("gbanlist", gbanlist)

GBAN_STATUS = CommandHandler("gbanstat", gbanstat, pass_args=True, filters=Filters.group)

GBAN_ENFORCER = MessageHandler(Filters.all & Filters.group, enforce_gban)

dispatcher.add_handler(GBAN_HANDLER)
dispatcher.add_handler(UNGBAN_HANDLER)
dispatcher.add_handler(GBAN_LIST)
dispatcher.add_handler(GBAN_STATUS)

__mod_name__ = "Global Bans"
__handlers__ = [GBAN_HANDLER, UNGBAN_HANDLER, GBAN_LIST, GBAN_STATUS]

if STRICT_GBAN:  # enforce GBANS if this is set
    dispatcher.add_handler(GBAN_ENFORCER, GBAN_ENFORCE_GROUP)
    __handlers__.append((GBAN_ENFORCER, GBAN_ENFORCE_GROUP))
Exemplo n.º 25
0
        else:
            wallpapers = json_rep.get("wallpapers")
            if not wallpapers:
                msg.reply_text("No results found! Refine your search.")
                return
            else:
                index = randint(0, len(wallpapers) - 1)  # Choose random index
                wallpaper = wallpapers[index]
                wallpaper = wallpaper.get("url_image")
                wallpaper = wallpaper.replace("\\", "")
                bot.send_photo(chat_id,
                               photo=wallpaper,
                               caption='Preview',
                               reply_to_message_id=msg_id,
                               timeout=60)
                bot.send_document(chat_id,
                                  document=wallpaper,
                                  filename='wallpaper',
                                  caption=caption,
                                  reply_to_message_id=msg_id,
                                  timeout=60)


__help__ = """
 - /wall <query>: get a a wallpaper from wall.alphacoders.com
"""

__mod_name__ = "Wallpaper"
WALL_HANDLER = DisableAbleCommandHandler("wall", wall, pass_args=True)
dispatcher.add_handler(WALL_HANDLER)
Exemplo n.º 26
0
def __migrate__(old_chat_id, new_chat_id):
    sql.migrate_chat(old_chat_id, new_chat_id)


def __chat_settings__(chat_id, user_id):
    limit = sql.get_flood_limit(chat_id)
    if limit == 0:
        return "*Not* currently enforcing flood control."
    else:
        return "Antiflood is set to `{}` messages.".format(limit)


__help__ = """
 - /flood: Get the current flood control setting

*Admin only:*
 - /setflood <int/'no'/'off'>: enables or disables flood control
"""

FLOOD_BAN_HANDLER = MessageHandler(Filters.all & ~Filters.status_update & Filters.group, check_flood)
SET_FLOOD_HANDLER = CommandHandler("setflood", set_flood, pass_args=True)
FLOOD_HANDLER = CommandHandler("flood", flood)

dispatcher.add_handler(FLOOD_BAN_HANDLER, FLOOD_GROUP)
dispatcher.add_handler(SET_FLOOD_HANDLER)
dispatcher.add_handler(FLOOD_HANDLER)

__mod_name__ = "AntiFlood"
__handlers__ = [(FLOOD_BAN_HANDLER, FLOOD_GROUP), SET_FLOOD_HANDLER, FLOOD_HANDLER]
Exemplo n.º 27
0
 - /get <notename>: get the note with this notename
 - #<notename>: same as /get
 - /notes or /saved: list all saved notes in this chat

If you would like to retrieve the contents of a note without any formatting, use `/get <notename> noformat`. This can \
be useful when updating a current note.

*Admin only:*
 - /save <notename> <notedata>: saves notedata as a note with name notename
A button can be added to a note by using standard markdown link syntax - the link should just be prepended with a \
`buttonurl:` section, as such: `[somelink](buttonurl:example.com)`. Check /markdownhelp for more info.
 - /save <notename>: save the replied message as a note with name notename
 - /clear <notename>: clear note with this name
"""

__mod_name__ = "Notes"

GET_HANDLER = CommandHandler("get", cmd_get, pass_args=True)
HASH_GET_HANDLER = RegexHandler(r"^#[^\s]+", hash_get)

SAVE_HANDLER = CommandHandler("save", save)
DELETE_HANDLER = CommandHandler("clear", clear, pass_args=True)

LIST_HANDLER = DisableAbleCommandHandler(["notes", "saved"], list_notes, admin_ok=True)

dispatcher.add_handler(GET_HANDLER)
dispatcher.add_handler(SAVE_HANDLER)
dispatcher.add_handler(LIST_HANDLER)
dispatcher.add_handler(DELETE_HANDLER)
dispatcher.add_handler(HASH_GET_HANDLER)
Exemplo n.º 28
0
    # RAM Usage
    svmem = psutil.virtual_memory()
    memm = "--- Memory Usage ---\n"
    memm += f"Total: `{get_size(svmem.total)}`\n"
    memm += f"Available: `{get_size(svmem.available)}`\n"
    memm += f"Used: `{get_size(svmem.used)}`\n"
    memm += f"Percentage: `{svmem.percent}%`\n"
    reply = str(stat) + str(softw) + str(cpuu) + str(memm) + "\n"
    bot.send_message(chat.id, reply, parse_mode=ParseMode.MARKDOWN)


__help__ = """
- /system : To know System status
- /speed or - /speedtest: To find Speed
"""

SPEED_TEST_HANDLER = DisableAbleCommandHandler(
    ["speedtest", "speed"], speedtestxyz, filters=CustomFilters.sudo_filter)
SPEED_TEST_CALLBACKHANDLER = CallbackQueryHandler(speedtestxyz_callback,
                                                  pattern='speedtest_.*')
STATUS_HANDLER = CommandHandler("system",
                                status,
                                filters=CustomFilters.sudo_filter)

dispatcher.add_handler(SPEED_TEST_HANDLER)
dispatcher.add_handler(SPEED_TEST_CALLBACKHANDLER)
dispatcher.add_handler(STATUS_HANDLER)

__mod_name__ = "SYSTEM INFO"
__command_list__ = ["speedtest"]
__handlers__ = [SPEED_TEST_HANDLER, SPEED_TEST_CALLBACKHANDLER]
Exemplo n.º 29
0
INTEGRATE_HANDLER = DisableAbleCommandHandler("integrate",
                                              integrate,
                                              pass_args=True)
ZEROES_HANDLER = DisableAbleCommandHandler("zeroes", zeroes, pass_args=True)
TANGENT_HANDLER = DisableAbleCommandHandler("tangent", tangent, pass_args=True)
AREA_HANDLER = DisableAbleCommandHandler("area", area, pass_args=True)
COS_HANDLER = DisableAbleCommandHandler("cos", cos, pass_args=True)
SIN_HANDLER = DisableAbleCommandHandler("sin", sin, pass_args=True)
TAN_HANDLER = DisableAbleCommandHandler("tan", tan, pass_args=True)
ARCCOS_HANDLER = DisableAbleCommandHandler("arccos", arccos, pass_args=True)
ARCSIN_HANDLER = DisableAbleCommandHandler("arcsin", arcsin, pass_args=True)
ARCTAN_HANDLER = DisableAbleCommandHandler("arctan", arctan, pass_args=True)
ABS_HANDLER = DisableAbleCommandHandler("abs", abs, pass_args=True)
LOG_HANDLER = DisableAbleCommandHandler("log", log, pass_args=True)

dispatcher.add_handler(SIMPLIFY_HANDLER)
dispatcher.add_handler(FACTOR_HANDLER)
dispatcher.add_handler(DERIVE_HANDLER)
dispatcher.add_handler(INTEGRATE_HANDLER)
dispatcher.add_handler(ZEROES_HANDLER)
dispatcher.add_handler(TANGENT_HANDLER)
dispatcher.add_handler(AREA_HANDLER)
dispatcher.add_handler(COS_HANDLER)
dispatcher.add_handler(SIN_HANDLER)
dispatcher.add_handler(TAN_HANDLER)
dispatcher.add_handler(ARCCOS_HANDLER)
dispatcher.add_handler(ARCSIN_HANDLER)
dispatcher.add_handler(ARCTAN_HANDLER)
dispatcher.add_handler(ABS_HANDLER)
dispatcher.add_handler(LOG_HANDLER)
Exemplo n.º 30
0
CLASSIC_HANDLER = DisableAbleCommandHandler("classic", classic)
KUNI_HANDLER = DisableAbleCommandHandler("kuni", kuni)
WAIFU_HANDLER = DisableAbleCommandHandler("waifu", waifu)
LEWD_HANDLER = DisableAbleCommandHandler("lewd", lewd)
KISS_HANDLER = DisableAbleCommandHandler("kiss", kiss)
FEMDOM_HANDLER = DisableAbleCommandHandler("femdom", femdom)
CUDDLE_HANDLER = DisableAbleCommandHandler("cuddle", cuddle)
EROK_HANDLER = DisableAbleCommandHandler("erok", erok)
FOXGIRL_HANDLER = DisableAbleCommandHandler("foxgirl", foxgirl)
TITSGIF_HANDLER = DisableAbleCommandHandler("titsgif", titsgif)
ERO_HANDLER = DisableAbleCommandHandler("ero", ero)
SMUG_HANDLER = DisableAbleCommandHandler("smug", smug)
BAKA_HANDLER = DisableAbleCommandHandler("baka", baka)
DVA_HANDLER = DisableAbleCommandHandler("dva", dva)

dispatcher.add_handler(LEWDKEMO_HANDLER)
dispatcher.add_handler(NEKO_HANDLER)
dispatcher.add_handler(FEET_HANDLER)
dispatcher.add_handler(YURI_HANDLER)
dispatcher.add_handler(TRAP_HANDLER)
dispatcher.add_handler(FUTANARI_HANDLER)
dispatcher.add_handler(HOLOLEWD_HANDLER)
dispatcher.add_handler(SOLOGIF_HANDLER)
dispatcher.add_handler(CUMGIF_HANDLER)
dispatcher.add_handler(EROKEMO_HANDLER)
dispatcher.add_handler(LESBIAN_HANDLER)
dispatcher.add_handler(WALLPAPER_HANDLER)
dispatcher.add_handler(LEWDK_HANDLER)
dispatcher.add_handler(NGIF_HANDLER)
dispatcher.add_handler(TICKLE_HANDLER)
dispatcher.add_handler(LEWD_HANDLER)