Ejemplo n.º 1
0

def __stats__():
    return "• `{}` notes, accross `{}` chats.".format(sql.num_notes(),
                                                      sql.num_chats())


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


__help__ = True

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

SAVE_HANDLER = CommandHandler("save", save)
REMOVE_ALL_NOTES_HANDLER = CommandHandler("clearall", remove_all_notes)
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)
dispatcher.add_handler(REMOVE_ALL_NOTES_HANDLER)
Ejemplo n.º 2
0
        return value
    except KeyError:
        return {"status": False, "value": False}


__help__ = True

NEW_FED_HANDLER = CommandHandler("newfed", new_fed)
DEL_FED_HANDLER = CommandHandler("delfed", del_fed, pass_args=True)
JOIN_FED_HANDLER = CommandHandler("joinfed", join_fed, pass_args=True)
LEAVE_FED_HANDLER = CommandHandler("leavefed", leave_fed, pass_args=True)
PROMOTE_FED_HANDLER = CommandHandler("fpromote", user_join_fed, pass_args=True)
DEMOTE_FED_HANDLER = CommandHandler("fdemote", user_demote_fed, pass_args=True)
INFO_FED_HANDLER = CommandHandler("fedinfo", fed_info, pass_args=True)
BAN_FED_HANDLER = DisableAbleCommandHandler(["fban", "fedban"],
                                            fed_ban,
                                            pass_args=True)
UN_BAN_FED_HANDLER = CommandHandler("unfban", unfban, pass_args=True)
FED_SET_RULES_HANDLER = CommandHandler("setfrules", set_frules, pass_args=True)
FED_GET_RULES_HANDLER = CommandHandler("frules", get_frules, pass_args=True)
FED_CHAT_HANDLER = CommandHandler("chatfed", fed_chat, pass_args=True)
FED_ADMIN_HANDLER = CommandHandler("fedadmins", fed_admin, pass_args=True)
FED_NOTIF_HANDLER = CommandHandler("fednotif", fed_notif, pass_args=True)
FED_CHATLIST_HANDLER = CommandHandler("fedchats", fed_chats, pass_args=True)

DELETEBTN_FED_HANDLER = CallbackQueryHandler(del_fed_button, pattern=r"rmfed_")

dispatcher.add_handler(NEW_FED_HANDLER)
dispatcher.add_handler(DEL_FED_HANDLER)
dispatcher.add_handler(JOIN_FED_HANDLER)
dispatcher.add_handler(LEAVE_FED_HANDLER)
Ejemplo n.º 3
0
    chat = update.effective_chat
    user = update.effective_user

    chatname = chat.title
    res = build_lock_message(chat, chat, user, chatname)

    update.effective_message.reply_text(res, parse_mode=ParseMode.MARKDOWN)


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


__help__ = True

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)
Ejemplo n.º 4
0

def check_afk(bot, update, user_id, fst_name, userc_id):
    chat = update.effective_chat
    if sql.is_afk(user_id):
        user = sql.check_afk_status(user_id)
        if not user.reason:
            if int(userc_id) == int(user_id):
                return
            res = tld(chat.id, "status_afk_noreason").format(fst_name)
            update.effective_message.reply_text(res)
        else:
            if int(userc_id) == int(user_id):
                return
            res = tld(chat.id,
                      "status_afk_reason").format(fst_name, user.reason)
            update.effective_message.reply_text(res)


__help__ = True

AFK_HANDLER = DisableAbleCommandHandler("afk", afk)
AFK_REGEX_HANDLER = DisableAbleRegexHandler("(?i)brb", afk, friendly="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)
Ejemplo n.º 5
0
        else:
            update.effective_message.reply_text(tld(chat.id,
                                                    "admin_err_wrong_arg"),
                                                parse_mode=ParseMode.MARKDOWN)
    else:
        status = sql.command_reaction(chat.id)
        update.effective_message.reply_text(tld(
            chat.id, "admin_reaction_status").format('enabled' if status ==
                                                     True else 'disabled'),
                                            parse_mode=ParseMode.MARKDOWN)


__help__ = True

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

INVITE_HANDLER = CommandHandler("invitelink", invite)

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

REACT_HANDLER = DisableAbleCommandHandler("reaction",
                                          reaction,
                                          pass_args=True,
                                          filters=Filters.group)
Ejemplo n.º 6
0
    repl = temp.format(user1=user1,
                       user2=user2,
                       item=item,
                       hits=hit,
                       throws=throw,
                       itemp=itemp,
                       itemr=itemr)

    reply_text(repl, parse_mode=ParseMode.MARKDOWN)


__help__ = True

OWO_HANDLER = DisableAbleCommandHandler("owo",
                                        owo,
                                        admin_ok=True,
                                        pass_args=True)
STRETCH_HANDLER = DisableAbleCommandHandler("stretch", stretch, pass_args=True)
VAPOR_HANDLER = DisableAbleCommandHandler("vapor",
                                          vapor,
                                          pass_args=True,
                                          admin_ok=True)
MOCK_HANDLER = DisableAbleCommandHandler("mock",
                                         spongemocktext,
                                         admin_ok=True,
                                         pass_args=True)
KIM_HANDLER = DisableAbleCommandHandler("kim",
                                        kimtext,
                                        admin_ok=True,
                                        pass_args=True)
MAFIA_HANDLER = DisableAbleCommandHandler("mafia",
Ejemplo n.º 7
0
    for fx in f_flist:
        sql.remove_filter(chat.id, fx)

    message.reply_text(tld(chat.id, "cust_filters_cleanup_success").format(x))


def __stats__():
    return "• `{}` filters, across `{}` chats.".format(sql.num_filters(),
                                                       sql.num_chats())


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


__help__ = True

FILTER_HANDLER = DisableAbleCommandHandler("filter", filters)
STOP_HANDLER = DisableAbleCommandHandler("stop", stop_filter)
STOPALL_HANDLER = DisableAbleCommandHandler("stopall", stop_all_filters)
LIST_HANDLER = DisableAbleCommandHandler("filters",
                                         list_handlers,
                                         admin_ok=True)
CUST_FILTER_HANDLER = MessageHandler(CustomFilters.has_text, reply_filter)

dispatcher.add_handler(FILTER_HANDLER)
dispatcher.add_handler(STOP_HANDLER)
dispatcher.add_handler(STOPALL_HANDLER)
dispatcher.add_handler(LIST_HANDLER)
dispatcher.add_handler(CUST_FILTER_HANDLER, HANDLER_GROUP)
Ejemplo n.º 8
0
def __stats__():
    return "• `{}` overall warns, across `{}` chats.\n" \
           "• `{}` warn filters, across `{}` chats.".format(sql.num_warns(), sql.num_warn_chats(),
                                                      sql.num_warn_filters(), sql.num_warn_filter_chats())


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


__help__ = True

WARN_HANDLER = DisableAbleCommandHandler("warn",
                                         warn_user,
                                         pass_args=True,
                                         filters=Filters.group,
                                         admin_ok=True)
RESET_WARN_HANDLER = DisableAbleCommandHandler(["resetwarn", "resetwarns"],
                                               reset_warns,
                                               pass_args=True,
                                               filters=Filters.group)
RMWARN_QUERY_HANDLER = CallbackQueryHandler(rmwarn_handler, pattern=r"rm_warn")
SENDRULES_QUERY_HANDLER = CallbackQueryHandler(sendrules_handler,
                                               pattern=r"send_rules")
MYWARNS_HANDLER = DisableAbleCommandHandler("warns",
                                            warns,
                                            pass_args=True,
                                            filters=Filters.group,
                                            admin_ok=True)
ADD_WARN_HANDLER = DisableAbleCommandHandler("addwarn",
Ejemplo n.º 9
0
    res = bot.restrict_chat_member(chat.id, user_id, can_send_messages=False)
    if res:
        update.effective_message.reply_text(tld(chat.id, "muteme_muted"))
        log = "<b>{}:</b>" \
              "\n#MUTEME" \
              "\n<b>User:</b> {}" \
              "\n<b>ID:</b> <code>{}</code>".format(html.escape(chat.title),
                                                    mention_html(user.id, user.first_name), user_id)
        return log

    else:
        update.effective_message.reply_text(tld(chat.id, "mute_cant_mute"))


MUTE_HANDLER = DisableAbleCommandHandler("mute",
                                         mute,
                                         pass_args=True,
                                         admin_ok=True)
UNMUTE_HANDLER = DisableAbleCommandHandler("unmute",
                                           unmute,
                                           pass_args=True,
                                           admin_ok=True)
TEMPMUTE_HANDLER = DisableAbleCommandHandler(["tmute", "tempmute"],
                                             temp_mute,
                                             pass_args=True,
                                             admin_ok=True)
TEMP_NOMEDIA_HANDLER = DisableAbleCommandHandler(["trestrict", "temprestrict"],
                                                 temp_nomedia,
                                                 pass_args=True,
                                                 admin_ok=True)
NOMEDIA_HANDLER = DisableAbleCommandHandler(["restrict", "nomedia"],
                                            nomedia,
Ejemplo n.º 10
0
def __migrate__(old_chat_id, new_chat_id):
    sql.migrate_chat(old_chat_id, new_chat_id)


def __stats__():
    return "• `{}` blacklist triggers, across `{}` chats.".format(
        sql.num_blacklist_filters(), sql.num_blacklist_filter_chats())


__help__ = True

#TODO: Add blacklist alternative modes: warn, ban, kick, or mute.

BLACKLIST_HANDLER = DisableAbleCommandHandler("blacklist",
                                              blacklist,
                                              pass_args=True,
                                              admin_ok=True)
ADD_BLACKLIST_HANDLER = CommandHandler("addblacklist", add_blacklist)
UNBLACKLIST_HANDLER = CommandHandler(["unblacklist", "rmblacklist"],
                                     unblacklist)
BLACKLIST_DEL_HANDLER = MessageHandler(
    (Filters.text | Filters.command | Filters.sticker | Filters.photo)
    & Filters.group,
    del_blacklist,
    edited_updates=True)

dispatcher.add_handler(BLACKLIST_HANDLER)
dispatcher.add_handler(ADD_BLACKLIST_HANDLER)
dispatcher.add_handler(UNBLACKLIST_HANDLER)
dispatcher.add_handler(BLACKLIST_DEL_HANDLER, group=BLACKLIST_GROUP)
Ejemplo n.º 11
0
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            return log
        else:
            LOGGER.warning(update)
            LOGGER.exception("ERROR banning user %s in chat %s (%s) due to %s",
                             user_id, chat.title, chat.id, excp.message)
    return ""


__help__ = True

BAN_HANDLER = DisableAbleCommandHandler("ban",
                                        ban,
                                        pass_args=True,
                                        filters=Filters.group,
                                        admin_ok=True)
TEMPBAN_HANDLER = DisableAbleCommandHandler(["tban", "tempban"],
                                            temp_ban,
                                            pass_args=True,
                                            filters=Filters.group,
                                            admin_ok=True)
KICK_HANDLER = DisableAbleCommandHandler("kick",
                                         kick,
                                         pass_args=True,
                                         filters=Filters.group,
                                         admin_ok=True)
UNBAN_HANDLER = DisableAbleCommandHandler("unban",
                                          unban,
                                          pass_args=True,
Ejemplo n.º 12
0
    base_string = tld(chat.id, "url_blacklist_current")
    blacklisted = sql.get_blacklisted_urls(chat.id)

    if not blacklisted:
        message.reply_text(tld(chat.id, "url_blacklist_no_existed"))
        return
    for domain in blacklisted:
        base_string += "- <code>{}</code>\n".format(domain)

    message.reply_text(base_string, parse_mode=ParseMode.HTML)


URL_BLACKLIST_HANDLER = DisableAbleCommandHandler("blacklist",
                                                  add_blacklist_url,
                                                  filters=Filters.group,
                                                  pass_args=True,
                                                  admin_ok=True)
ADD_URL_BLACKLIST_HANDLER = CommandHandler("addurl",
                                           add_blacklist_url,
                                           filters=Filters.group)

RM_BLACKLIST_URL_HANDLER = CommandHandler("delurl",
                                          rm_blacklist_url,
                                          filters=Filters.group)

GET_BLACKLISTED_URLS = CommandHandler("geturl",
                                      get_blacklisted_urls,
                                      filters=Filters.group)

URL_DELETE_HANDLER = MessageHandler(Filters.entity("url"),
Ejemplo n.º 13
0
    for char in s:
        count = count + 1
        if count % 3 == 0:
            if len(s) == count:
                result = char + result
            else:
                result = thousand_separator + char + result
        else:
            result = char + result
    return result


__help__ = True

ID_HANDLER = DisableAbleCommandHandler("id",
                                       get_id,
                                       pass_args=True,
                                       admin_ok=True)
IP_HANDLER = CommandHandler("ip", get_bot_ip, filters=Filters.chat(OWNER_ID))
INFO_HANDLER = DisableAbleCommandHandler("info",
                                         info,
                                         pass_args=True,
                                         admin_ok=True)
GITHUB_HANDLER = DisableAbleCommandHandler("git", github, admin_ok=True)
REPO_HANDLER = DisableAbleCommandHandler("repo",
                                         repo,
                                         pass_args=True,
                                         admin_ok=True)

ECHO_HANDLER = CommandHandler("echo", echo, filters=Filters.user(OWNER_ID))
MD_HELP_HANDLER = CommandHandler("markdownhelp",
                                 markdown_help,
Ejemplo n.º 14
0
def __user_info__(user_id, chat_id):
    bio = html.escape(sql.get_user_bio(user_id) or "")
    me = html.escape(sql.get_user_me_info(user_id) or "")
    if bio and me:
        return tld(chat_id, "userinfo_what_i_and_other_say").format(me, bio)
    elif bio:
        return tld(chat_id, "userinfo_what_other_say").format(bio)
    elif me:
        return tld(chat_id, "userinfo_what_i_say").format(me)
    else:
        return ""


def __gdpr__(user_id):
    sql.clear_user_info(user_id)
    sql.clear_user_bio(user_id)


__help__ = True

SET_BIO_HANDLER = DisableAbleCommandHandler("setbio", set_about_bio)
GET_BIO_HANDLER = DisableAbleCommandHandler("bio", about_bio, pass_args=True)

SET_ABOUT_HANDLER = DisableAbleCommandHandler("setme", set_about_me)
GET_ABOUT_HANDLER = DisableAbleCommandHandler("me", about_me, pass_args=True)

dispatcher.add_handler(SET_BIO_HANDLER)
dispatcher.add_handler(GET_BIO_HANDLER)
dispatcher.add_handler(SET_ABOUT_HANDLER)
dispatcher.add_handler(GET_ABOUT_HANDLER)