コード例 #1
0
- /addfsticker | afs <custom name>: Reply to a sticker to add it into your favorite pack list.
- /myfsticker | mfs: Get list of your favorite packs.
- /removefsticker | rfs <custom name>: Reply to a sticker to remove it into your favorite pack list.

*Example:* `/addfsticker my cat pack`
"""

__mod_name__ = "Stickers"
KANG_HANDLER = DisableAbleCommandHandler("addsticker",
                                         addsticker,
                                         pass_args=True)
DEL_HANDLER = DisableAbleCommandHandler("delsticker", delsticker)
STICKERID_HANDLER = DisableAbleCommandHandler("stickerid", stickerid)
ADD_FSTICKER_HANDLER = DisableAbleCommandHandler(["addfsticker", "afs"],
                                                 add_fvrtsticker,
                                                 pass_args=True)
REMOVE_FSTICKER_HANDLER = DisableAbleCommandHandler(["removefsticker", "rfs"],
                                                    remove_fvrtsticker,
                                                    pass_args=True)
MY_FSTICKERS_HANDLER = DisableAbleCommandHandler(["myfsticker", "mfs"],
                                                 list_fvrtsticker)
GETSTICKER_HANDLER = DisableAbleCommandHandler("getsticker", getsticker)

dispatcher.add_handler(KANG_HANDLER)
dispatcher.add_handler(DEL_HANDLER)
dispatcher.add_handler(STICKERID_HANDLER)
dispatcher.add_handler(ADD_FSTICKER_HANDLER)
dispatcher.add_handler(REMOVE_FSTICKER_HANDLER)
dispatcher.add_handler(MY_FSTICKERS_HANDLER)
dispatcher.add_handler(GETSTICKER_HANDLER)
コード例 #2
0
ファイル: locks.py プロジェクト: SurajRaj4542/Celluloid
 - /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, locking stickers will restrict all \
non-admin users from sending stickers, etc.
Locking bots will stop non-admins from adding bots to the chat.

Note:
 • Unlocking permission *info* will allow members (non-admins) to change the group information, such as the description or the group name
 • Unlocking permission *pin* will allow members (non-admins) to pinned a message in a group
"""

__mod_name__ = "Locks"

LOCKTYPES_HANDLER = DisableAbleCommandHandler("locktypes", locktypes)
LOCK_HANDLER = CommandHandler("lock", lock,
                              pass_args=True)  # , filters=Filters.group)
UNLOCK_HANDLER = CommandHandler("unlock", unlock,
                                pass_args=True)  # , filters=Filters.group)
LOCKED_HANDLER = CommandHandler("locks",
                                list_locks)  # , filters=Filters.group)

dispatcher.add_handler(LOCK_HANDLER)
dispatcher.add_handler(UNLOCK_HANDLER)
dispatcher.add_handler(LOCKTYPES_HANDLER)
dispatcher.add_handler(LOCKED_HANDLER)

dispatcher.add_handler(
    MessageHandler(Filters.all & Filters.group, del_lockables), PERM_GROUP)
コード例 #3
0
ファイル: admin.py プロジェクト: SurajRaj4542/Celluloid
                                 filters=Filters.group)

PROMOTE_HANDLER = CommandHandler("promote",
                                 promote,
                                 pass_args=True,
                                 filters=Filters.group)
DEMOTE_HANDLER = CommandHandler("demote",
                                demote,
                                pass_args=True,
                                filters=Filters.group)

SET_TITLE_HANDLER = DisableAbleCommandHandler("settitle",
                                              set_title,
                                              pass_args=True)
ADMINLIST_HANDLER = DisableAbleCommandHandler(["adminlist", "admins"],
                                              adminlist,
                                              filters=Filters.group)

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(ADMINLIST_HANDLER)
dispatcher.add_handler(SET_TITLE_HANDLER)
dispatcher.add_handler(CHAT_PIC_HANDLER)
dispatcher.add_handler(DEL_CHAT_PIC_HANDLER)
dispatcher.add_handler(SETCHAT_TITLE_HANDLER)
dispatcher.add_handler(SETSTICKET_HANDLER)
dispatcher.add_handler(SETDESC_HANDLER)
コード例 #4
0
ファイル: memes.py プロジェクト: SurajRaj4542/Celluloid
MEETOO_HANDLER = DisableAbleMessageHandler(Filters.regex(r"(?i)(me too)"),
                                           me_too,
                                           friendly="metoo")
RECITE_HANDLER = DisableAbleCommandHandler("recite", recite)
DICE_HANDLER = DisableAbleCommandHandler("roll", dice)
YESNOWTF_HANDLER = DisableAbleCommandHandler("decide", yesnowtf)
GDMORNING_HANDLER = DisableAbleMessageHandler(
    Filters.regex(r"(?i)(goodmorning|good morning)"),
    goodmorning,
    friendly="goodmorning")
GDNIGHT_HANDLER = DisableAbleMessageHandler(
    Filters.regex(r"(?i)(goodnight|good night)"),
    goodnight,
    friendly="goodnight")

dispatcher.add_handler(SHRUG_HANDLER)
dispatcher.add_handler(DECIDE_HANDLER)
dispatcher.add_handler(ABUSE_HANDLER)
dispatcher.add_handler(SNIPE_HANDLER)
dispatcher.add_handler(RUNS_HANDLER)
dispatcher.add_handler(SLAP_HANDLER)
dispatcher.add_handler(HUG_HANDLER)
dispatcher.add_handler(GBUN_HANDLER)
dispatcher.add_handler(TABLE_HANDLER)
dispatcher.add_handler(RECITE_HANDLER)
dispatcher.add_handler(CRI_HANDLER)
dispatcher.add_handler(PASTA_HANDLER)
dispatcher.add_handler(CLAP_HANDLER)
dispatcher.add_handler(OWO_HANDLER)
dispatcher.add_handler(STRECH_HANDLER)
dispatcher.add_handler(MEETOO_HANDLER)
コード例 #5
0
ファイル: wallpaper.py プロジェクト: SurajRaj4542/Celluloid
        try:
            wall_list = asyncio.run(walld(q))
        except:
            msg.reply_text("Error Occured!")
            return 
        if not wall_list:
            msg.reply_text("No results found! Check your query.")
            return
        else:
            index = randint(0, len(wall_list) - 1) 
            wallpaper = wall_list[index]
            url_w = wallpaper[0]
            context.bot.send_photo(
                    chat_id,
                    photo=url_w,
                    caption=wallpaper[1],
                    reply_to_message_id=msg_id,
                    timeout=60,
                )
            context.bot.send_document(
                    chat_id,
                    document=url_w,
                    filename=q,
                    caption=wallpaper[1],
                    reply_to_message_id=msg_id,
                    timeout=60,
                )

WALL_HANDLER = DisableAbleCommandHandler("wall", wall)
dispatcher.add_handler(WALL_HANDLER)
コード例 #6
0
ファイル: reporting.py プロジェクト: SurajRaj4542/Celluloid
__mod_name__ = "Reporting"

__help__ = """
We're all busy people who don't have time to monitor our groups 24/7. But how do you \
react if someone in your group is spamming?

Presenting reports; if someone in your group thinks someone needs reporting, they now have \
an easy way to call all admins.

*Admin only:*
 - /reports <on/off>: Change report setting, or view current status.
   • If done in pm, toggles your status.
   • If in chat, toggles that chat's status.

To report a user, simply reply to user's message with @admin or /report. \
This message tags all the chat admins; same as if they had been @'ed.
You MUST reply to a message to report a user; you can't just use @admin to tag admins for no reason!

Note that the report commands do not work when admins use them; or when used to report an admin. Bot assumes that \
admins don't need to report, or be reported!
"""
REPORT_HANDLER = CommandHandler("report", report, filters=Filters.group)
SETTING_HANDLER = CommandHandler("reports", report_setting, pass_args=True)
ADMIN_REPORT_HANDLER = MessageHandler(Filters.regex("(?i)@admin(s)?"), report)
REPORT_BUTTON_HANDLER = CallbackQueryHandler(report_buttons, pattern=r"report_")

dispatcher.add_handler(REPORT_HANDLER, REPORT_GROUP)
dispatcher.add_handler(ADMIN_REPORT_HANDLER, REPORT_GROUP)
dispatcher.add_handler(SETTING_HANDLER)
dispatcher.add_handler(REPORT_BUTTON_HANDLER)
コード例 #7
0
ファイル: afk.py プロジェクト: hyper-ub/Shoko
    return text


def __gdpr__(user_id):
    end_afk(user_id)



__mod_name__ = "AFK"


__help__ = """
  - /afk <reason>: Mark yourself as AFK.
  - brb <reason>: Same as the afk command, but not a command.\n
  When marked as AFK, any mentions will be replied to with a message stating that you're not available!
"""


AFK_HANDLER = DisableAbleCommandHandler("afk", afk)
AFK_REGEX_HANDLER = MessageHandler(Filters.regex("(?i)brb"), afk)
NO_AFK_HANDLER = MessageHandler(Filters.all & Filters.group, no_longer_afk)
AFK_REPLY_HANDLER = MessageHandler(Filters.all & Filters.group, reply_afk)

dispatcher.add_handler(AFK_HANDLER, AFK_GROUP)
dispatcher.add_handler(AFK_REGEX_HANDLER, AFK_GROUP)
dispatcher.add_handler(NO_AFK_HANDLER, AFK_GROUP)
dispatcher.add_handler(AFK_REPLY_HANDLER, AFK_REPLY_GROUP)



コード例 #8
0
Log channels can help you keep track of exactly what the other admins are doing. \
Bans, Mutes, warns, notes - everything can be moderated.

*Admin only:*
- /logchannel: Get log channel info
- /setlog: Set the log channel.
- /unsetlog: Unset the log channel.

Setting the log channel is done by:
- Add the bot to your channel, as an admin. This is done via the "add administrators" tab.
- Send /setlog to your channel.
- Forward the /setlog command to the group you wish to be logged.
- Congratulations! All is set!
"""

    __mod_name__ = "Logger"

    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
コード例 #9
0
            dl_file = download.text
            size = trs[i].find("span", {"class": "filesize"}).text
            reply += f"[{dl_file}]({dl_link}) - {size}\n"

        update.message.reply_text(
            "{}".format(reply),
            parse_mode=ParseMode.MARKDOWN,
            disable_web_page_preview=True,
        )


__help__ = """
Get Latest magisk relese, Twrp for your device or info about some device using its codename, Directly from Bot!

*Android related commands:*

 - /magisk - Gets the latest magisk release for Stable/Beta/Canary.
 - /device <codename> - Gets android device basic info from its codename.
 - /twrp <codename> -  Gets latest twrp for the android device using the codename.
"""

__mod_name__ = "Android"

MAGISK_HANDLER = DisableAbleCommandHandler("magisk", magisk)
DEVICE_HANDLER = DisableAbleCommandHandler("device", device, pass_args=True)
TWRP_HANDLER = DisableAbleCommandHandler("twrp", twrp, pass_args=True)

dispatcher.add_handler(MAGISK_HANDLER)
dispatcher.add_handler(DEVICE_HANDLER)
dispatcher.add_handler(TWRP_HANDLER)
コード例 #10
0
ファイル: notes.py プロジェクト: unknown-01-hacker/Shoko
`/save notename` while replying to a sticker or whatever data you'd like. Now, the note at "#notename" contains a sticker which will be sent as a reply.

Tip: to retrieve a note without the formatting, use /get <notename> noformat
This will retrieve the note and send it without formatting it; getting you the raw markdown, allowing you to make easy edits.
"""

__mod_name__ = "Notes"

GET_HANDLER = CommandHandler("get", cmd_get, pass_args=True)
HASH_GET_HANDLER = MessageHandler(Filters.regex(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)
CLEARALLNOTES_HANDLER = CommandHandler("clearall",
                                       clear_notes,
                                       filters=Filters.group)

RMBTN_HANDLER = CallbackQueryHandler(rmbutton, pattern=r"rmnotes_")

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)
dispatcher.add_handler(CLEARALLNOTES_HANDLER)
dispatcher.add_handler(RMBTN_HANDLER)
コード例 #11
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):
    blacklisted = sql.num_stickers_chat_filters(chat_id)
    return "There are `{} `blacklisted stickers.".format(blacklisted)


def __stats__():
    return "• {} blacklist stickers, across {} chats.".format(
        sql.num_stickers_filters(), sql.num_stickers_filter_chats())


BLACKLIST_STICKER_HANDLER = DisableAbleCommandHandler(
    "blsticker", blackliststicker, admin_ok=True)
ADDBLACKLIST_STICKER_HANDLER = DisableAbleCommandHandler(
    "addblsticker", add_blackliststicker)
UNBLACKLIST_STICKER_HANDLER = CommandHandler(["unblsticker", "rmblsticker"],
                                             unblackliststicker)
BLACKLISTMODE_HANDLER = CommandHandler("blstickermode", blacklist_mode)
BLACKLIST_STICKER_DEL_HANDLER = MessageHandler(Filters.sticker & Filters.group,
                                               del_blackliststicker)

dispatcher.add_handler(BLACKLIST_STICKER_HANDLER)
dispatcher.add_handler(ADDBLACKLIST_STICKER_HANDLER)
dispatcher.add_handler(UNBLACKLIST_STICKER_HANDLER)
dispatcher.add_handler(BLACKLISTMODE_HANDLER)
dispatcher.add_handler(BLACKLIST_STICKER_DEL_HANDLER)
コード例 #12
0
ファイル: dbcleanup.py プロジェクト: SurajRaj4542/Celluloid
            chat_count = get_muted_chats(bot, update, True)
            bot.sendMessage(chat_id, f"Left {chat_count} chats.")
        else:
            query.answer("You are not allowed to use this.")
    elif query_type == "db_cleanup":
        if query.from_user.id in admin_list:
            bot.editMessageText("Cleaning up DB ...", chat_id,
                                message.message_id)
            invalid_chat_count = get_invalid_chats(bot, update, True)
            invalid_gban_count = get_invalid_gban(bot, update, True)
            reply = "Cleaned up {} chats and {} gbanned users from db.".format(
                invalid_chat_count, invalid_gban_count)
            bot.sendMessage(chat_id, reply)
        else:
            query.answer("You are not allowed to use this.")


DB_CLEANUP_HANDLER = CommandHandler("dbcleanup",
                                    dbcleanup,
                                    filters=Filters.chat(OWNER_ID))
LEAVE_MUTED_CHATS_HANDLER = CommandHandler("leavemutedchats",
                                           leave_muted_chats,
                                           filters=Filters.chat(OWNER_ID))
BUTTON_HANDLER = CallbackQueryHandler(callback_button, pattern="db_.*")

dispatcher.add_handler(DB_CLEANUP_HANDLER)
dispatcher.add_handler(LEAVE_MUTED_CHATS_HANDLER)
dispatcher.add_handler(BUTTON_HANDLER)

__handlers__ = [DB_CLEANUP_HANDLER, LEAVE_MUTED_CHATS_HANDLER, BUTTON_HANDLER]
コード例 #13
0
ファイル: weather.py プロジェクト: SurajRaj4542/Celluloid
        temp = str(round((c - k)))
        return temp

    def fahr(c):
        c1 = 9 / 5
        c2 = 459.67
        tF = c * c1 - c2
        if tF < 0 and tF > -1:
            tF = 0
        temp = str(round(tF))
        return temp

    reply = f"*Current weather for {cityname}, {country_name} is*:\n\n*Temperature:* `{celsius(curtemp)}°C ({fahr(curtemp)}ºF), feels like {celsius(feels_like)}°C ({fahr(feels_like)}ºF) \n`*Condition:* `{condmain}, {conddet}` {icon}\n*Humidity:* `{humidity}%`\n*Wind:* `{kmph[0]} km/h`\n"
    del_msg = update.effective_message.reply_text(
        "{}".format(reply), parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True
    )
    time.sleep(30)
    try:
        del_msg.delete()
        update.effective_message.delete()
    except BadRequest as err:
        if (err.message == "Message to delete not found") or (
            err.message == "Message can't be deleted"
        ):
            return


WEATHER_HANDLER = DisableAbleCommandHandler("weather", weather, pass_args=True)

dispatcher.add_handler(WEATHER_HANDLER)
コード例 #14
0
__mod_name__ = "Connection"

__help__ = """
Sometimes, you just want to add some notes and filters to a group chat, but you don't want everyone to see; This is where connections come in...
This allows you to connect to a chat's database, and add things to it without the commands appearing in chat! For obvious reasons, you need to be an admin to add things; but any member in the group can view your data.

 - /connect: Connects to chat (Can be done in a group by /connect or /connect <chat id> in PM)
 - /connection: List connected chats
 - /disconnect: Disconnect from a chat
 - /helpconnect: List available commands that can be used remotely

*Admin only:*
 - /allowconnect <yes/no>: allow a user to connect to a chat
"""

CONNECT_CHAT_HANDLER = CommandHandler("connect", connect_chat, pass_args=True)
CONNECTION_CHAT_HANDLER = CommandHandler("connection", connection_chat)
DISCONNECT_CHAT_HANDLER = CommandHandler("disconnect", disconnect_chat)
ALLOW_CONNECTIONS_HANDLER = CommandHandler("allowconnect",
                                           allow_connections,
                                           pass_args=True)
HELP_CONNECT_CHAT_HANDLER = CommandHandler("helpconnect", help_connect_chat)
CONNECT_BTN_HANDLER = CallbackQueryHandler(connect_button, pattern=r"connect")

dispatcher.add_handler(CONNECT_CHAT_HANDLER)
dispatcher.add_handler(CONNECTION_CHAT_HANDLER)
dispatcher.add_handler(DISCONNECT_CHAT_HANDLER)
dispatcher.add_handler(ALLOW_CONNECTIONS_HANDLER)
dispatcher.add_handler(HELP_CONNECT_CHAT_HANDLER)
dispatcher.add_handler(CONNECT_BTN_HANDLER)
コード例 #15
0
ファイル: warns.py プロジェクト: SurajRaj4542/Celluloid
)
ADD_WARN_HANDLER = CommandHandler("addwarn", add_warn_filter, filters=Filters.group)
RM_WARN_HANDLER = CommandHandler(
    ["nowarn", "stopwarn"], remove_warn_filter, filters=Filters.group
)
LIST_WARN_HANDLER = DisableAbleCommandHandler(
    ["warnlist", "warnfilters"], list_warn_filters, filters=Filters.group, admin_ok=True
)
WARN_FILTER_HANDLER = MessageHandler(
    CustomFilters.has_text & Filters.group, reply_filter
)
WARN_LIMIT_HANDLER = CommandHandler(
    "warnlimit", set_warn_limit, pass_args=True, filters=Filters.group
)
WARN_STRENGTH_HANDLER = CommandHandler(
    "strongwarn", set_warn_strength, pass_args=True, filters=Filters.group
)

dispatcher.add_handler(WARN_HANDLER)
dispatcher.add_handler(CALLBACK_QUERY_HANDLER)
dispatcher.add_handler(SENDRULES_QUERY_HANDLER)
dispatcher.add_handler(RESET_WARN_HANDLER)
dispatcher.add_handler(REMOVE_WARNS_HANDLER)
dispatcher.add_handler(MYWARNS_HANDLER)
dispatcher.add_handler(ADD_WARN_HANDLER)
dispatcher.add_handler(RM_WARN_HANDLER)
dispatcher.add_handler(LIST_WARN_HANDLER)
dispatcher.add_handler(WARN_LIMIT_HANDLER)
dispatcher.add_handler(WARN_STRENGTH_HANDLER)
dispatcher.add_handler(WARN_FILTER_HANDLER, WARN_HANDLER_GROUP)
コード例 #16
0
TAG_ALL_HANDLER = DisableAbleCommandHandler("tagall",
                                            tagall,
                                            filters=Filters.group)
UNTAG_ALL_HANDLER = DisableAbleCommandHandler("untagall",
                                              untagall,
                                              filters=Filters.group)
UNTAG_ME_HANDLER = DisableAbleCommandHandler("untagme",
                                             untagme,
                                             filters=Filters.group)
TAG_ME_HANDLER = DisableAbleCommandHandler("tagme",
                                           tagme,
                                           filters=Filters.group)
ADD_TAG_HANDLER = DisableAbleCommandHandler("addtag",
                                            addtag,
                                            pass_args=True,
                                            filters=Filters.group)
REMOVE_TAG_HANDLER = DisableAbleCommandHandler("removetag",
                                               removetag,
                                               pass_args=True,
                                               filters=Filters.group)
TAGALL_CALLBACK_HANDLER = CallbackQueryHandler(tagg_all_button,
                                               pattern=r"tagall_")

dispatcher.add_handler(TAG_ALL_HANDLER)
dispatcher.add_handler(UNTAG_ALL_HANDLER)
dispatcher.add_handler(UNTAG_ME_HANDLER)
dispatcher.add_handler(TAG_ME_HANDLER)
dispatcher.add_handler(ADD_TAG_HANDLER)
dispatcher.add_handler(REMOVE_TAG_HANDLER)
dispatcher.add_handler(TAGALL_CALLBACK_HANDLER)
コード例 #17
0
    status += "<b>Machine:</b> <code>" + str(uname.machine) + "</code>\n"
    status += "<b>Processor:</b> <code>" + str(uname.processor) + "</code>\n\n"

    mem = virtual_memory()
    cpu = cpu_percent()
    disk = disk_usage("/")
    status += "<b>CPU usage:</b> <code>" + str(cpu) + " %</code>\n"
    status += "<b>Ram usage:</b> <code>" + str(mem[2]) + " %</code>\n"
    status += "<b>Storage used:</b> <code>" + str(disk[3]) + " %</code>\n\n"
    status += "<b>Python version:</b> <code>" + python_version() + "</code>\n"
    status += "<b>Library version:</b> <code>" + str(__version__) + "</code>\n"
    status += "<b>Spamwatch API:</b> <code>" + str(__sw__) + "</code>\n"
    context.bot.sendMessage(update.effective_chat.id,
                            status,
                            parse_mode=ParseMode.HTML)


IP_HANDLER = CommandHandler("ip", get_bot_ip, filters=Filters.chat(OWNER_ID))
PING_HANDLER = CommandHandler("ping", ping, filters=CustomFilters.sudo_filter)
SPEED_HANDLER = CommandHandler("speedtest",
                               speedtst,
                               filters=CustomFilters.sudo_filter)
SYS_STATUS_HANDLER = CommandHandler("sysinfo",
                                    system_status,
                                    filters=CustomFilters.sudo_filter)

dispatcher.add_handler(IP_HANDLER)
dispatcher.add_handler(SPEED_HANDLER)
dispatcher.add_handler(PING_HANDLER)
dispatcher.add_handler(SYS_STATUS_HANDLER)
コード例 #18
0
    return results


def scam(imgspage, lim):
    """Parse/Scrape the HTML code for the info we want."""

    single = opener.open(imgspage).read()
    decoded = single.decode("utf-8")
    if int(lim) > 10:
        lim = 10

    imglinks = []
    counter = 0

    pattern = r"^,\[\"(.*[.png|.jpg|.jpeg])\",[0-9]+,[0-9]+\]$"
    oboi = re.findall(pattern, decoded, re.I | re.M)

    for imglink in oboi:
        counter += 1
        imglinks.append(imglink)
        if counter >= int(lim):
            break

    return imglinks


REVERSE_HANDLER = DisableAbleCommandHandler("reverse", reverse, pass_args=True)

dispatcher.add_handler(REVERSE_HANDLER)
コード例 #19
0
ファイル: muting.py プロジェクト: Nobita567/Dasha
            context.bot.answer_callback_query(
                query.id,
                text="You don't have enough rights to delete this message.",
                show_alert=True)
            return ""
        else:
            query.message.delete()
            context.bot.answer_callback_query(query.id, text="Deleted!")
            return ""


MUTE_HANDLER = CommandHandler("mute",
                              mute,
                              pass_args=True,
                              filters=Filters.group)
UNMUTE_HANDLER = CommandHandler("unmute",
                                unmute,
                                pass_args=True,
                                filters=Filters.group)
TEMPMUTE_HANDLER = CommandHandler(["tmute", "tempmute"],
                                  temp_mute,
                                  pass_args=True,
                                  filters=Filters.group)
MBUTTON_CALLBACK_HANDLER = CallbackQueryHandler(muteb_callback,
                                                pattern=r"muteb_")

dispatcher.add_handler(MUTE_HANDLER)
dispatcher.add_handler(UNMUTE_HANDLER)
dispatcher.add_handler(TEMPMUTE_HANDLER)
dispatcher.add_handler(MBUTTON_CALLBACK_HANDLER)
コード例 #20
0
"""

__mod_name__ = "Bans"

BAN_HANDLER = CommandHandler("ban", ban, pass_args=True, filters=Filters.group)
TEMPBAN_HANDLER = CommandHandler(["tban", "tempban"],
                                 temp_ban,
                                 pass_args=True,
                                 filters=Filters.group)
KICK_HANDLER = CommandHandler("kick",
                              kick,
                              pass_args=True,
                              filters=Filters.group)
UNBAN_HANDLER = CommandHandler("unban",
                               unban,
                               pass_args=True,
                               filters=Filters.group)
KICKME_HANDLER = DisableAbleCommandHandler("kickme",
                                           kickme,
                                           filters=Filters.group)
BANME_HANDLER = DisableAbleCommandHandler("banme",
                                          banme,
                                          filters=Filters.group)

dispatcher.add_handler(BAN_HANDLER)
dispatcher.add_handler(TEMPBAN_HANDLER)
dispatcher.add_handler(KICK_HANDLER)
dispatcher.add_handler(UNBAN_HANDLER)
dispatcher.add_handler(KICKME_HANDLER)
dispatcher.add_handler(BANME_HANDLER)
コード例 #21
0
                                     welcomemute,
                                     pass_args=True,
                                     filters=Filters.group)
CLEAN_SERVICE_HANDLER = CommandHandler("cleanservice",
                                       cleanservice,
                                       pass_args=True,
                                       filters=Filters.group)
GETTIMESET_HANDLER = CommandHandler("kicktime", getTimeSetting)
SETTIMER_HANDLER = CommandHandler("setkicktime",
                                  setTimeSetting,
                                  pass_args=True)
WELCOME_HELP = CommandHandler("welcomehelp", welcome_help)
BUTTON_VERIFY_HANDLER = CallbackQueryHandler(user_button,
                                             pattern=r"user_join_")

dispatcher.add_handler(NEW_MEM_HANDLER)
dispatcher.add_handler(LEFT_MEM_HANDLER)
dispatcher.add_handler(WELC_PREF_HANDLER)
dispatcher.add_handler(GOODBYE_PREF_HANDLER)
dispatcher.add_handler(SET_WELCOME)
dispatcher.add_handler(SET_GOODBYE)
dispatcher.add_handler(RESET_WELCOME)
dispatcher.add_handler(RESET_GOODBYE)
dispatcher.add_handler(CLEAN_WELCOME)
dispatcher.add_handler(GETTIMESET_HANDLER)
dispatcher.add_handler(SETTIMER_HANDLER)
dispatcher.add_handler(WELCOMEMUTE_HANDLER)
dispatcher.add_handler(CLEAN_SERVICE_HANDLER)
dispatcher.add_handler(BUTTON_VERIFY_HANDLER)
dispatcher.add_handler(WELCOME_HELP)
コード例 #22
0
ファイル: disable.py プロジェクト: SurajRaj4542/Celluloid
left unused; to avoid spam and abuse.

This allows you to disable some commonly used commands, so noone can use them. \
It'll also allow you to autodelete them, stopping people from bluetexting.

 - /cmds: Check the current status of disabled commands

*Admin only:*
 - /enable <cmd name>: Enable that command
 - /disable <cmd name>: Disable that command
 - /listcmds: List all possible disablable commands
    """

    DISABLE_HANDLER = CommandHandler(
        "disable", disable, pass_args=True)  # , filters=Filters.group)
    ENABLE_HANDLER = CommandHandler("enable", enable,
                                    pass_args=True)  # , filters=Filters.group)
    COMMANDS_HANDLER = CommandHandler(["cmds", "disabled"],
                                      commands)  # , filters=Filters.group)
    TOGGLE_HANDLER = CommandHandler("listcmds",
                                    list_cmds)  # , filters=Filters.group)

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

else:
    DisableAbleCommandHandler = CommandHandler
    DisableAbleMessageHandler = MessageHandler
コード例 #23
0
ファイル: rules.py プロジェクト: OfficialErenYeager/Celluloid

def __chat_settings__(chat_id, user_id):
    return "This chat has had it's rules set: `{}`".format(
        bool(sql.get_rules(chat_id)))


__help__ = """
Every chat works with different rules; this module will help make those rules clearer!

 - /rules: get the rules for this chat.

*Admin only:*
 - /setrules <your rules here>: Sets rules for the chat.
 - /clearrules: Clears saved rules for the chat.
"""

__mod_name__ = "Rules"

GET_RULES_HANDLER = CommandHandler("rules", get_rules, filters=Filters.group)
SET_RULES_HANDLER = CommandHandler("setrules",
                                   set_rules,
                                   filters=Filters.group)
RESET_RULES_HANDLER = CommandHandler("clearrules",
                                     clear_rules,
                                     filters=Filters.group)

dispatcher.add_handler(GET_RULES_HANDLER)
dispatcher.add_handler(SET_RULES_HANDLER)
dispatcher.add_handler(RESET_RULES_HANDLER)
コード例 #24
0
MD_HELP_HANDLER = CommandHandler("markdownhelp",
                                 markdown_help,
                                 filters=Filters.private)
STATS_HANDLER = DisableAbleCommandHandler("stats",
                                          stats,
                                          filters=CustomFilters.sudo_filter)
GDPR_HANDLER = CommandHandler("gdpr", gdpr, filters=Filters.private)
WIKI_HANDLER = DisableAbleCommandHandler("wiki", wiki)
UD_HANDLER = DisableAbleCommandHandler("ud", ud)
GETLINK_HANDLER = CommandHandler("getlink",
                                 getlink,
                                 pass_args=True,
                                 filters=Filters.user(OWNER_ID))
STAFFLIST_HANDLER = CommandHandler("slist",
                                   slist,
                                   filters=Filters.user(OWNER_ID))
REDDIT_MEMES_HANDLER = DisableAbleCommandHandler("rmeme", rmemes)
SRC_HANDLER = CommandHandler("source", src, filters=Filters.private)

dispatcher.add_handler(INFO_HANDLER)
dispatcher.add_handler(UD_HANDLER)
dispatcher.add_handler(ECHO_HANDLER)
dispatcher.add_handler(MD_HELP_HANDLER)
dispatcher.add_handler(STATS_HANDLER)
dispatcher.add_handler(GDPR_HANDLER)
dispatcher.add_handler(WIKI_HANDLER)
dispatcher.add_handler(GETLINK_HANDLER)
dispatcher.add_handler(STAFFLIST_HANDLER)
dispatcher.add_handler(REDDIT_MEMES_HANDLER)
dispatcher.add_handler(SRC_HANDLER)
コード例 #25
0
def main():
    # test_handler = CommandHandler("test", test)
    start_handler = CommandHandler("start", start, pass_args=True)
    start_p_handler = CallbackQueryHandler(start_p, pattern=r"start_")

    help_handler = CommandHandler("help", get_help)
    help_callback_handler = CallbackQueryHandler(help_button, pattern=r"help_")

    gethelp_callback_handler = CallbackQueryHandler(gethelp,
                                                    pattern=r"gethelp_")

    settings_handler = CommandHandler("settings", get_settings)
    settings_callback_handler = CallbackQueryHandler(settings_button,
                                                     pattern=r"stngs_")

    about_callback_handler = CallbackQueryHandler(Shoko_about_callback,
                                                  pattern=r"aboutmanu_")

    migrate_handler = MessageHandler(Filters.status_update.migrate,
                                     migrate_chats)
    is_chat_allowed_handler = MessageHandler(Filters.group, is_chat_allowed)

    # dispatcher.add_handler(test_handler)
    dispatcher.add_handler(start_handler)
    dispatcher.add_handler(start_p_handler)
    dispatcher.add_handler(about_callback_handler)
    dispatcher.add_handler(help_handler)
    dispatcher.add_handler(gethelp_callback_handler)
    dispatcher.add_handler(settings_handler)
    dispatcher.add_handler(help_callback_handler)
    dispatcher.add_handler(settings_callback_handler)
    dispatcher.add_handler(migrate_handler)
    dispatcher.add_handler(is_chat_allowed_handler)

    dispatcher.add_error_handler(error_handler)

    if WEBHOOK:
        LOGGER.info("Using webhooks.")
        updater.start_webhook(listen="0.0.0.0", port=PORT, url_path=TOKEN)

        if CERT_PATH:
            updater.bot.set_webhook(url=URL + TOKEN,
                                    certificate=open(CERT_PATH, "rb"))
        else:
            updater.bot.set_webhook(url=URL + TOKEN)
            client.run_until_disconnected()

    else:
        LOGGER.info("Using long polling.")
        updater.start_polling(timeout=15, read_latency=4)
        client.run_until_disconnected()

    updater.idle()
コード例 #26
0
ファイル: backups.py プロジェクト: SurajRaj4542/Celluloid
        status = True
    chat_data[chat_id] = {"backups": {"status": status, "value": value}}


def get_chat(chat_id, chat_data):
    # print(chat_data)
    try:
        value = chat_data[chat_id]["backups"]
        return value
    except KeyError:
        return {"status": False, "value": False}


__mod_name__ = "Backups"

__help__ = """
*Only for chat administrator:*

 - /import: Reply to the backup file for the butler / emilia group to import as much as possible, making transfers very easy! \
 Note that files / photos cannot be imported due to telegram restrictions.

 - /export: Export group data, which will be exported are: rules, notes (documents, images, music, video, audio, voice, text, text buttons) \

"""

IMPORT_HANDLER = CommandHandler("import", import_data)
EXPORT_HANDLER = CommandHandler("export", export_data, pass_chat_data=True)

dispatcher.add_handler(IMPORT_HANDLER)
dispatcher.add_handler(EXPORT_HANDLER)
コード例 #27
0
USER_HANDLER = DisableAbleCommandHandler("user", user)
UPCOMING_HANDLER = DisableAbleCommandHandler("upcoming", upcoming)
WATCHLIST_HANDLER = DisableAbleCommandHandler("watchlist", watchlist)
MANGALIST_HANDLER = DisableAbleCommandHandler("mangalist", readmanga)
FVRT_CHAR_HANDLER = DisableAbleCommandHandler(["characterlist", "fcl"],
                                              fvrtchar)
REMOVE_WATCHLIST_HANDLER = DisableAbleCommandHandler(
    ["removewatchlist", "rwl"], removewatchlist)
REMOVE_FVRT_CHAR_HANDLER = DisableAbleCommandHandler(["rfcharacter", "rfcl"],
                                                     removefvrtchar)
REMOVE_MANGA_CHAR_HANDLER = DisableAbleCommandHandler(["rmanga", "rml"],
                                                      removemangalist)
BUTTON_HANDLER = CallbackQueryHandler(button, pattern='anime_.*')
ANIME_STUFFS_HANDLER = CallbackQueryHandler(animestuffs, pattern='xanime_.*')

dispatcher.add_handler(BUTTON_HANDLER)
dispatcher.add_handler(ANIME_STUFFS_HANDLER)
dispatcher.add_handler(ANIME_HANDLER)
dispatcher.add_handler(CHARACTER_HANDLER)
dispatcher.add_handler(MANGA_HANDLER)
dispatcher.add_handler(AIRING_HANDLER)
dispatcher.add_handler(USER_HANDLER)
dispatcher.add_handler(UPCOMING_HANDLER)
dispatcher.add_handler(WATCHLIST_HANDLER)
dispatcher.add_handler(MANGALIST_HANDLER)
dispatcher.add_handler(FVRT_CHAR_HANDLER)
dispatcher.add_handler(REMOVE_FVRT_CHAR_HANDLER)
dispatcher.add_handler(REMOVE_MANGA_CHAR_HANDLER)
dispatcher.add_handler(REMOVE_WATCHLIST_HANDLER)

__mod_name__ = "Anime"
コード例 #28
0
 - /setflood <int/'no'/'off'>: enables or disables flood control
 - /setfloodmode <ban/kick/mute/tban/tmute> <value>: Action to perform when user have exceeded flood limit. ban/kick/mute/tmute/tban

 Note:
 - Value must be filled for tban and tmute!

 It can be:
 5m = 5 minutes
 6h = 6 hours
 3d = 3 days
 1w = 1 week
 """

__mod_name__ = "Antiflood"

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

dispatcher.add_handler(FLOOD_BAN_HANDLER, FLOOD_GROUP)
dispatcher.add_handler(SET_FLOOD_HANDLER)
dispatcher.add_handler(SET_FLOOD_MODE_HANDLER)
dispatcher.add_handler(FLOOD_HANDLER)
コード例 #29
0
    "gban",
    gban,
    pass_args=True,
    filters=CustomFilters.sudo_filter | CustomFilters.support_filter,
)
UNGBAN_HANDLER = CommandHandler(
    "ungban",
    ungban,
    pass_args=True,
    filters=CustomFilters.sudo_filter | CustomFilters.support_filter,
)
GBAN_LIST = CommandHandler(
    "gbanlist",
    gbanlist,
    filters=CustomFilters.sudo_filter | CustomFilters.support_filter,
)
GBAN_STATUS = CommandHandler("antispam",
                             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)

if STRICT_GBAN:  # enforce GBANS if this is set
    dispatcher.add_handler(GBAN_ENFORCER, GBAN_ENFORCE_GROUP)
コード例 #30
0
ファイル: regex.py プロジェクト: SurajRaj4542/Celluloid
                text = re.sub(repl, repl_with, to_fix, flags=re.I).strip()
            elif "i" in flags:
                text = re.sub(repl, repl_with, to_fix, count=1,
                              flags=re.I).strip()
            elif "g" in flags:
                text = re.sub(repl, repl_with, to_fix).strip()
            else:
                text = re.sub(repl, repl_with, to_fix, count=1).strip()
        except sre_constants.error:
            LOGGER.warning(update.effective_message.text)
            LOGGER.exception("SRE constant error")
            update.effective_message.reply_text(
                "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)


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

dispatcher.add_handler(SED_HANDLER)