Exemplo n.º 1
0
    Delete exceptions in a chat
    :param update: object representing the incoming update.
    :param context: object containing data about the command call.
    """
    if update.effective_chat.type == "private":
        update.effective_message.reply_text(
            "You can't delete exceptions in private chats.")
        return

    for command in context.args:
        reply = del_command_exception_chats(command, update.effective_chat.id)
        update.effective_message.reply_markdown(reply)


__help__ = """
Adding an exception for a bot_action in your chat will change it's behaviour. How it will change depends on the bot_action.

- /listexceptions : list all exceptions in chat

- /addexceptions `<commands list>` : Add exceptions for given commands (space separated)

- /delexceptions `<commands list>` : Delete exceptions for given commands (space separated)
"""

__mod_name__ = "Exceptions"

# create handlers
dispatcher.add_handler(CommandHandler('listexceptions', list_exceptions))
dispatcher.add_handler(CommandHandler('addexceptions', add_exception))
dispatcher.add_handler(CommandHandler('delexceptions', del_exception))
Exemplo n.º 2
0
***Admin only :***

- /promote `<reply|username> [<title>]` : promotes a user (whose username you've given as argument, or whose message you are quoting) to admin

- /demote `<reply|username>` : demotes an admin (whose username you've given as argument, or whose message you are quoting)

- /mute `<reply|username> [x<m|h|d>]` : mutes a user (whose username you've given as argument, or whose message you are quoting) for x time, or until they are un-muted. m = minutes, h = hours, d = days.

- /unmute `<reply|username>`: un-mutes a user (whose username you've given as argument, or whose message you are quoting)

- /ban `<reply|username> [x<m|h|d>]`: ban a user from the chat (whose username you've given as argument, or whose message you are quoting) for x time, or until they are added back. m = minutes, h = hours, d = days.

- /kick `<reply|username>` : kick a user from the chat (whose username you've given as argument, or whose message you are quoting)

- /purge `<reply>` : delete all messages from replied message to current one.

If you add an exception to `admin`, I will allow admins to execute commands even if they don't have the individual permissions.
"""

__mod_name__ = "Admin"

# create handlers
dispatcher.add_handler(CommandHandler("promote", promote))
dispatcher.add_handler(CommandHandler("demote", demote))
dispatcher.add_handler(CommandHandler("mute", mute))
dispatcher.add_handler(CommandHandler("unmute", unmute))
dispatcher.add_handler(CommandHandler("ban", ban))
dispatcher.add_handler(CommandHandler("kick", kick))
dispatcher.add_handler(CommandHandler("pin", pin))
dispatcher.add_handler(CommandHandler("purge", purge))
Exemplo n.º 3
0
    reply += user.mention_markdown(
        name="Click here to properly check this kitten out")

    # send user info
    update.effective_message.reply_markdown(reply)


__mod_name__ = "Basics"

__help__ = """
- /help `[<modules list>]` : Display the help text to understand how to use this bot

- /start : Start the bot! Gives a small welcome message

- /talk `[<word>]` : Say <word> (or meow, if not given) rendum number of times

- /modules : List all the active modules

- /id `[<reply|username>]` : Get details of current chat and a user (by replying to their message or giving their username) or yourself

- /fileid `<reply>` : Get file ID of the file in the quoted message
"""

# create handlers
dispatcher.add_handler(CommandHandler("start", start, run_async=True))
dispatcher.add_handler(CommandHandler("talk", talk, run_async=True))
dispatcher.add_handler(CommandHandler("help", help, run_async=True))
dispatcher.add_handler(CommandHandler("modules", list_modules, run_async=True))
dispatcher.add_handler(CommandHandler("id", info, run_async=True))
dispatcher.add_handler(CommandHandler("fileid", get_file_id, run_async=True))
Exemplo n.º 4
0
        text_blob = f"<code>{digits}</code>\n<a href='https://telegra.ph/{article_path}'>{title}</a>"
        for key, value in data.items():
            if value:
                text_blob += f"\n\n<code>{key}</code>\n{value}"

        # send message
        if exception:
            update.message.reply_html(text_blob)
        else:
            context.bot.send_message(chat_id=update.effective_user.id,
                                     text=text_blob,
                                     parse_mode=ParseMode.HTML)

    # if called from a chat without exception in it, then send him a reminder to check it
    if not exception and update.effective_chat.type != "private":
        update.message.reply_markdown(
            f"[Let's enjoy this together in our private chat...](https://t.me/{escape_markdown(context.bot.username)}"
        )


__help__ = """
- /sauce `<digits list>` : Read a doujin from nhentai.net in telegram instant preview by giving it's 5/6 digit code. 
You can give multiple codes, and it will fetch all those doujins. 
If you don't have an exception set for your chat, it'll send it to you in your private chat.
"""

__mod_name__ = "nhentai"

# create handlers
dispatcher.add_handler(CommandHandler('sauce', sauce))
Exemplo n.º 5
0
            photo=update.effective_message.reply_to_message.video,
            caption=result.decode("utf-8"),
            reply_markup=update.effective_message.reply_to_message.
            reply_markup,
        )
    else:
        update.effective_message.reply_to_message.reply_text(
            result.decode("utf-8"))


__mod_name__ = "Regex"

__help__ = f"""
- `s/<text1>/<text2>/[<flags>]` : 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 {MAX_MESSAGE_LENGTH} characters.

*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: \\?.

Add an exception to `regex` to disable this module.
"""

# ad handlers
dispatcher.add_handler(
    MessageHandler(Filters.regex(compile("^s([/:|_]).*([/:|_]).*")),
                   regex,
                   run_async=True))
Exemplo n.º 6
0
    try:
        file_name = _message_to_sticker(update, context)
    except AttributeError:
        update.effective_message.reply_text(
            "Please reply to a message to get its quote...\nThis cat can't read your mind!"
        )
        return

    # for future usage
    add_user(
        user_id=update.effective_message.reply_to_message.from_user.id,
        username=update.effective_message.reply_to_message.from_user.username,
    )

    # send generated image as sticker
    update.effective_message.reply_sticker(sticker=open(file_name, "rb"))

    # remove stored image
    if isfile(file_name):
        remove(file_name)


__help__ = """
- /quote `<reply>` : Reply to a message to get it's quote as a sticker.
"""

__mod_name__ = "quote"

# create handlers
dispatcher.add_handler(CommandHandler('quote', quote))
Exemplo n.º 7
0
    aesthetic_text = text.translate(dict((i, i + 0xFEE0) for i in range(0x21, 0x7F)))  # make text more aesthetic

    # reply with more aesthetics
    if context.args:
        update.effective_message.reply_markdown(f"`{aesthetic_text}`")
    else:
        update.effective_message.reply_to_message.reply_markdown(f"`{aesthetic_text}`")


__help__ = """
- /mock `<reply|message>` : MoCk LikE sPOnGEbob

- /zalgofy `<reply|message>` : cͩ͠o̴͕r͌̈ȓ͡ṵ̠p̟͜tͯ͞ t̷͂ḣ͞ȩ͗ t̪̉e̢̪x̨͑t̼ͨ

- /owo `<reply|message>` : translate normie to moe weeb

- /stretch `<reply|message>` : talk like the sloth from zootopia

- /vapor `<reply|message>` : vaporwave aesthetics
"""

__mod_name__ = "memes"

# create handlers
dispatcher.add_handler(CommandHandler("runs", runs, run_async=True))
dispatcher.add_handler(CommandHandler("mock", mock, run_async=True))
dispatcher.add_handler(CommandHandler("zalgofy", zalgofy, run_async=True))
dispatcher.add_handler(CommandHandler("owo", owo, run_async=True))
dispatcher.add_handler(CommandHandler("stretch", stretch, run_async=True))
dispatcher.add_handler(CommandHandler("vapor", vapor, run_async=True))
Exemplo n.º 8
0
    reply += user.mention_markdown(name="Click here to properly check this kitten out")

    # send user info
    update.effective_message.reply_markdown(reply)


__mod_name__ = "Basics"

__help__ = """
- /help `[<modules list>]` : Display the help text to understand how to use this bot

- /start : Start the bot! Gives a small welcome message

- /talk `[<word>]` : Say <word> (or meow, if not given) rendum number of times

- /modules : List all the active modules

- /id : Get the user and chat ID

- /info `[<reply|username>]` : Get details of a user (by replying to their message or giving their username) or yourself
"""


# create handlers
dispatcher.add_handler(CommandHandler("start", start))
dispatcher.add_handler(CommandHandler("talk", talk))
dispatcher.add_handler(CommandHandler("help", help))
dispatcher.add_handler(CommandHandler("modules", list_modules))
dispatcher.add_handler(CommandHandler("id", get_id))
dispatcher.add_handler(CommandHandler("info", info))
Exemplo n.º 9
0
    """
    if context.args:
        try:
            result = get(f'https://api.urbandictionary.com/v0/define?term={" ".join(context.args)}').json()["list"][0]
            update.effective_message.reply_markdown(
                f"***{result['word']}***\n\n{result['definition']}",
                reply_markup=InlineKeyboardMarkup.from_button(
                    InlineKeyboardButton(text="Click here to learn more", url=result["permalink"])
                ),
            )
        except IndexError:
            update.effective_message.reply_markdown(
                "Urban Dictionary doesn't know the answer to this, ask God or offer tuna to a passing cat to gain the "
                "wisdom you seek. Preferably the second option. When I'm passing by."
            )
    else:
        update.effective_message.reply_markdown(
            f"***{update.effective_user.first_name}***\n\n"
            f"A dumbass eternally high on cheap catnip who doesn't know that I can't get a word's "
            f"meaning they don't tell me what the bloody word is.\n\n",
        )


__help__ = """
 - /ud `<word>`: Type the word or expression you want to search use.
 """

__mod_name__ = "Urban-Dictionary"

dispatcher.add_handler(CommandHandler("ud", ud, run_async=True))
Exemplo n.º 10
0
    try:
        file_name = _message_to_sticker(update, context)
    except AttributeError:
        update.effective_message.reply_text(
            "Please reply to a message to get its quote...\nThis cat can't read your mind!"
        )
        return

    # for future usage
    add_user(
        user_id=update.effective_message.reply_to_message.from_user.id,
        username=update.effective_message.reply_to_message.from_user.username,
    )

    # send generated image as sticker
    update.effective_message.reply_sticker(sticker=open(file_name, "rb"))

    # remove stored image
    if isfile(file_name):
        remove(file_name)


__help__ = """
- /quote `<reply>` : Reply to a message to get it's quote as a sticker.
"""

__mod_name__ = "quote"

# create handlers
dispatcher.add_handler(CommandHandler("quote", quote, run_async=True))
Exemplo n.º 11
0
    # reply with more aesthetics
    if context.args:
        update.effective_message.reply_markdown(f"`{aesthetic_text}`")
    else:
        update.effective_message.reply_to_message.reply_markdown(
            f"`{aesthetic_text}`")


__help__ = """
- /mock `<reply>` : MoCk LikE sPOnGEbob

- /zalgofy `<reply>` : cͩ͠o̴͕r͌̈ȓ͡ṵ̠p̟͜tͯ͞ t̷͂ḣ͞ȩ͗ t̪̉e̢̪x̨͑t̼ͨ

- /owo `<reply>` : translate normie to moe weeb

- /stretch `<reply>` : talk like the sloth from zootopia

- /vapor `[<reply>|<message>]` : vaporwave aesthetics
"""

__mod_name__ = "memes"

# create handlers
dispatcher.add_handler(CommandHandler("runs", runs))
dispatcher.add_handler(CommandHandler("mock", mock))
dispatcher.add_handler(CommandHandler("zalgofy", zalgofy))
dispatcher.add_handler(CommandHandler("owo", owo))
dispatcher.add_handler(CommandHandler("stretch", stretch))
dispatcher.add_handler(CommandHandler("vapor", vapor))
Exemplo n.º 12
0
                msg.reply_document(content)
            elif filter_type == "photo":
                msg.reply_photo(content)
            elif filter_type == "audio":
                msg.reply_audio(content)
            elif filter_type == "voice":
                msg.reply_voice(content)
            elif filter_type == "video":
                msg.reply_video(content)

            break


__help__ = """
- /filters : list all active filters in the chat

- /filter `<trigger> [<content>|<reply>]` : add a filter

- /stop `<triggers list>` : delete active filters; give all filters to delete seperated by a space.

If you add an exception for `filter` in the chat, it will make sure that none of these commands do anything. Adding exceptions for individual commands has no effect.
"""

__mod_name__ = "Filters"

# create handlers
dispatcher.add_handler(CommandHandler("filters", list_filters))
dispatcher.add_handler(CommandHandler("filter", add_filter_handler))
dispatcher.add_handler(CommandHandler("stop", del_filter_handler))
dispatcher.add_handler(MessageHandler(Filters.all, reply), group=69)
Exemplo n.º 13
0
- /packs : list out all of your packs

- /kang `<reply> [<emojis>]` : reply to a sticker (animated or non animated) or a picture to add it to your pack. Won't do anything if you have an exception set in the chat.

- /migrate `<reply>` : reply to a sticker (animated or non animated) to migrate the entire sticker set it belongs to into your pack(s).

- /delsticker `<reply>` : reply to a sticker (animated or non animated) belonging to a pack made by me to remove it from said pack.

- /reorder `<reply>` [<new position>] : reply to a sticker (animated or non animated) belonging to a pack made by me to change it's position (index starting from 0) in the pack.
"""

__mod_name__ = "Stickers"

# create handlers
dispatcher.add_handler(CommandHandler("stickerid", sticker_id, run_async=True))
dispatcher.add_handler(
    CommandHandler("getsticker", get_sticker, run_async=True))
dispatcher.add_handler(CommandHandler("kang", kang, run_async=True))
dispatcher.add_handler(CommandHandler("migrate", migrate, run_async=True))
dispatcher.add_handler(
    CommandHandler("delsticker", del_sticker, run_async=True))
dispatcher.add_handler(CommandHandler("packs", packs, run_async=True))
dispatcher.add_handler(
    ConversationHandler(
        entry_points=[CommandHandler("reorder", reorder1, run_async=True)],
        states={
            0: [MessageHandler(Filters.sticker, reorder2, run_async=True)]
        },
        fallbacks=[CommandHandler("cancel", reorder_cancel, run_async=True)],
    ))
Exemplo n.º 14
0
            context.bot.send_photo(
                chat_id=update.effective_user.id,
                photo=doujin.image_urls[0],
                caption=text_blob,
                parse_mode=ParseMode.HTML,
                reply_markup=markup,
            )

    # if called from a chat without exception in it, then send him a reminder to check it
    if not exception and update.effective_chat.type != "private":
        update.message.reply_text(
            "Let's enjoy this together, without anybody else distracting us...",
            reply_markup=InlineKeyboardMarkup.from_button(
                InlineKeyboardButton(
                    text="Go to Private Chat",
                    url=context.bot.link,
                )),
        )


__help__ = """
- /sauce `<digits list>` : Read a doujin from nhentai.net in telegram instant preview by giving it's code. 
You can give multiple codes, and it will fetch all those doujins. 
If you don't have an exception set for your chat, it'll send it to you in your private chat.
"""

__mod_name__ = "nhentai"

# create handlers
dispatcher.add_handler(CommandHandler("sauce", sauce, run_async=True))
Exemplo n.º 15
0
@run_async
@bot_action("urban dict")
def ud(update: Update, context: CallbackContext):
    """
    Reply with all the imported modules
    :param update: object representing the incoming update.
    :param context: object containing data about the command call.
    """
    results = get(
        f'http://api.urbandictionary.com/v0/define?term={" ".join(context.args)}'
    ).json()
    reply_text = (
        (f"***Word***: {' '.join(context.args)}\n\n"
         f"***Definition***:\n{results['list'][0]['definition']}\n\n"
         f"[Click here to learn more]({results['list'][0]['permalink']})")
        if results.get('list') else
        ("Urban Dictionary doesn't know the answer to this, "
         "ask God or offer tuna to a passing cat to gain the wisdom you seek. "
         "Preferably the second option. When I'm passing by."))
    update.effective_message.reply_markdown(reply_text,
                                            disable_web_page_preview=True)


__help__ = """
 - /ud `<word>`: Type the word or expression you want to search use.
 """

__mod_name__ = "Urban-Dictionary"

dispatcher.add_handler(CommandHandler("ud", ud))
Exemplo n.º 16
0
- /stickerid `<reply>` : reply to a sticker (animated or non animated) to me to tell you its file ID.

- /getsticker `<reply>` : reply to a sticker (non animated) to me to upload its raw PNG file.

- /packs : list out all of your packs

- /kang `<reply> [<emojis>]` : reply to a sticker (animated or non animated) or a picture to add it to your pack. Won't do anything if you have an exception set in the chat.

- /migrate `<reply>` : reply to a sticker (animated or non animated) to migrate the entire sticker set it belongs to into your pack(s).

- /delsticker `<reply>` : reply to a sticker (animated or non animated) belonging to a pack made by me to remove it from said pack.

- /reorder `<reply>` [<new position>] : reply to a sticker (animated or non animated) belonging to a pack made by me to change it's position (index starting from 0) in the pack.
"""

__mod_name__ = "Stickers"

# create handlers
dispatcher.add_handler(CommandHandler("stickerid", sticker_id))
dispatcher.add_handler(CommandHandler("getsticker", get_sticker))
dispatcher.add_handler(CommandHandler('kang', kang))
dispatcher.add_handler(CommandHandler('migrate', migrate))
dispatcher.add_handler(CommandHandler('delsticker', del_sticker))
dispatcher.add_handler(CommandHandler('packs', packs))
dispatcher.add_handler(
    ConversationHandler(
        entry_points=[CommandHandler("reorder", reorder1)],
        states={0: [MessageHandler(Filters.sticker, reorder2)]},
        fallbacks=[CommandHandler("cancel", reorder_cancel)],
    ))
Exemplo n.º 17
0
    if update.effective_chat.type == "private":
        update.effective_message.reply_text(
            "You can't delete exceptions in private chats.")
        return

    for command in context.args:
        reply = del_command_exception_chats(command, update.effective_chat.id)
        update.effective_message.reply_markdown(reply)


__help__ = """
Adding an exception for a bot_action in your chat will change it's behaviour. How it will change depends on the bot_action.

- /exceptions : list all exceptions in chat

***Admin Only***

- /except `<commands list>` : Add exceptions for given commands (space separated)

- /delexcept `<commands list>` : Delete exceptions for given commands (space separated)
"""

__mod_name__ = "Exceptions"

# create handlers
dispatcher.add_handler(
    CommandHandler("exceptions", list_exceptions, run_async=True))
dispatcher.add_handler(CommandHandler("except", add_exception, run_async=True))
dispatcher.add_handler(
    CommandHandler("delexcept", del_exception, run_async=True))
Exemplo n.º 18
0
__help__ = """
- /pin `<reply> [silent|quiet]` : pin replied message in the chat.

***Admin only :***

- /promote `<reply|username> [<title>]` : promotes a user (whose username you've given as argument, or whose message you are quoting) to admin

- /demote `<reply|username>` : demotes an admin (whose username you've given as argument, or whose message you are quoting)

- /mute `<reply|username> [x<m|h|d>]` : mutes a user (whose username you've given as argument, or whose message you are quoting) for x time, or until they are un-muted. m = minutes, h = hours, d = days.

- /unmute `<reply|username>`: un-mutes a user (whose username you've given as argument, or whose message you are quoting)

- /ban `<reply|username> [x<m|h|d>]`: ban a user from the chat (whose username you've given as argument, or whose message you are quoting) for x time, or until they are added back. m = minutes, h = hours, d = days.

- /kick `<reply|username>` : kick a user from the chat (whose username you've given as argument, or whose message you are quoting)

If you add an exception to `admin`, I will allow admins to execute commands even if they don't have the individual permissions.
"""

__mod_name__ = "Admin"

# create handlers
dispatcher.add_handler(CommandHandler("promote", promote, run_async=True))
dispatcher.add_handler(CommandHandler("demote", demote, run_async=True))
dispatcher.add_handler(CommandHandler("mute", mute, run_async=True))
dispatcher.add_handler(CommandHandler("unmute", unmute, run_async=True))
dispatcher.add_handler(CommandHandler("ban", ban, run_async=True))
dispatcher.add_handler(CommandHandler("kick", kick, run_async=True))
dispatcher.add_handler(CommandHandler("pin", pin, run_async=True))
Exemplo n.º 19
0
            elif filter_type == "voice":
                msg.reply_voice(content)
            elif filter_type == "video":
                msg.reply_video(content)

            break


__help__ = """
- /filters : list all active filters in the chat

*Admin Only*

- /filter `<trigger> [<content>|<reply>]` : add a filter

- /stop `<triggers list>` : delete active filters; give all filters to delete seperated by a space.

If you add an exception for `filter` in the chat, it will make sure that none of these commands do anything. Adding exceptions for individual commands has no effect.
"""

__mod_name__ = "Filters"

# create handlers
dispatcher.add_handler(CommandHandler("filters", list_filters, run_async=True))
dispatcher.add_handler(
    CommandHandler("filter", add_filter_handler, run_async=True))
dispatcher.add_handler(
    CommandHandler("stop", del_filter_handler, run_async=True))
dispatcher.add_handler(MessageHandler(Filters.all, reply, run_async=True),
                       group=69)
Exemplo n.º 20
0
        update.effective_message.reply_markdown(
            "Oi, you can't make me forget something without reminding me of what to forget, baka!"
        )


__help__ = """
- /get <note name>: get the note with this note name

- `#<note name>`: same as /get

- /notes or /saved: list all saved notes in this chat
 
***Admin only :***

- /save `<note name> <reply|note data>`: saves replied message or `note data` as a note with name `note name`.

- /clear <note names list>: clear note with this name

If you add an exception for `notes` in the chat, it will make sure that none of these commands do anything. Adding exceptions for individual commands has no effect.
"""

__mod_name__ = "Notes"

# create handlers
dispatcher.add_handler(CommandHandler("get", fetch_note, run_async=True))
dispatcher.add_handler(MessageHandler(Filters.regex(r"^#[^\s].+$"), fetch_note, run_async=True))
dispatcher.add_handler(CommandHandler("notes", notes_for_chat, run_async=True))
dispatcher.add_handler(CommandHandler("saved", notes_for_chat, run_async=True))
dispatcher.add_handler(CommandHandler("save", add_note_in_chat, run_async=True))
dispatcher.add_handler(CommandHandler("clear", del_note_in_chat, run_async=True))
Exemplo n.º 21
0
COMMANDS = [
    BotCommand(
        command='help',
        description="Display the help text to understand how to use this bot"),
    BotCommand(command='random', description="Get a random word"),
    BotCommand(command='all', description="Get all words in order"),
    BotCommand(
        command='search',
        description="Gets words with this substring in word or meaning fields."
    ),
    BotCommand(command='clear', description="Clears word cache"),
]

if __name__ == "__main__":
    # create handlers
    dispatcher.add_handler(CommandHandler("start", start))
    dispatcher.add_handler(CommandHandler("random", random))
    dispatcher.add_handler(CommandHandler("all", allWords))
    dispatcher.add_handler(CommandHandler("search", search))
    dispatcher.add_handler(CommandHandler("help", help))
    dispatcher.add_handler(CommandHandler("clear", clear))

    if config.DB_NAME:
        connect(config.DB_NAME, 'default', host=config.DB_URI)

    updater.bot.set_my_commands(COMMANDS)

    updater.start_polling()

    print("WordBot thot")
    updater.idle()