Ejemplo n.º 1
0
@run_async
@user_admin
def gettime(update: Update, context: CallbackContext):
    message = update.effective_message

    try:
        query = message.text.strip().split(" ", 1)[1]
    except BaseException:
        message.reply_text(
            "Provide a country name/abbreviation/timezone to find.")
        return
    send_message = message.reply_text(
        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)

TIME_HANDLER = CommandHandler("datetime", gettime)
dispatcher.add_handler(TIME_HANDLER)
Ejemplo n.º 2
0
WELC_PREF_HANDLER = CommandHandler("welcome", welcome, filters=Filters.group)
GOODBYE_PREF_HANDLER = CommandHandler("goodbye", goodbye, filters=Filters.group)
SET_WELCOME = CommandHandler("setwelcome", set_welcome, filters=Filters.group)
SET_GOODBYE = CommandHandler("setgoodbye", set_goodbye, filters=Filters.group)
RESET_WELCOME = CommandHandler("resetwelcome", reset_welcome, filters=Filters.group)
RESET_GOODBYE = CommandHandler("resetgoodbye", reset_goodbye, filters=Filters.group)
WELCOMEMUTE_HANDLER = CommandHandler("welcomemute", welcomemute, filters=Filters.group)
CLEAN_SERVICE_HANDLER = CommandHandler(
    "cleanservice", cleanservice, filters=Filters.group
)
CLEAN_WELCOME = CommandHandler("cleanwelcome", clean_welcome, filters=Filters.group)
WELCOME_HELP = CommandHandler("welcomehelp", welcome_help)
WELCOME_MUTE_HELP = CommandHandler("welcomemutehelp", welcome_mute_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(WELCOME_HELP)
dispatcher.add_handler(WELCOMEMUTE_HANDLER)
dispatcher.add_handler(CLEAN_SERVICE_HANDLER)
dispatcher.add_handler(BUTTON_VERIFY_HANDLER)
dispatcher.add_handler(WELCOME_MUTE_HELP)

__mod_name__ = "Greetings 👋"
Ejemplo n.º 3
0
    else:
        update.message.reply_text("Maybe.")


def table(update, context):
    r = randint(1, 100)
    if r <= 45:
        update.message.reply_text("(╯°□°)╯彡 ┻━┻")
    elif r <= 90:
        update.message.reply_text("Send money bsdk to buy new table to flip")
    else:
        update.message.reply_text(
            "Go do some work instead of flippin tables you helpless fagit.")


ABUSE_HANDLER = CommandHandler("abuse", abuse)
ROLL_HANDLER = CommandHandler("roll", roll)
TOSS_HANDLER = CommandHandler("toss", toss)
# BLUETEXT_HANDLER = CommandHandler("bluetext", bluetext)
RLG_HANDLER = CommandHandler("rlg", rlg)
DECIDE_HANDLER = CommandHandler("decide", decide)
TABLE_HANDLER = CommandHandler("table", table)

dispatcher.add_handler(ABUSE_HANDLER)
dispatcher.add_handler(ROLL_HANDLER)
dispatcher.add_handler(TOSS_HANDLER)
# dispatcher.add_handler(BLUETEXT_HANDLER)
dispatcher.add_handler(RLG_HANDLER)
dispatcher.add_handler(DECIDE_HANDLER)
dispatcher.add_handler(TABLE_HANDLER)
Ejemplo n.º 4
0
            msg.reply_text(f"An error occurred! Report this {SUPPORT_CHAT}")
        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,
                )


WALLPAPER_HANDLER = CommandHandler("wall", wall)
dispatcher.add_handler(WALLPAPER_HANDLER)
Ejemplo n.º 5
0
            message.reply_text("No log channel has been set yet!")

    def __stats__():
        return "× {} log channels have been set.".format(sql.num_logchannels())

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

    def __chat_settings__(chat_id, user_id):
        log_channel = sql.get_chat_log_channel(chat_id)
        if log_channel:
            log_channel_info = dispatcher.bot.get_chat(log_channel)
            return "This group has all it's logs sent to: {} (`{}`)".format(
                escape_markdown(log_channel_info.title), log_channel)
        return "No log channel is set for this group!"

    __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
Ejemplo n.º 6
0
            end = change.get("To") + 1
            suggestions = change.get("Suggestions")
            if suggestions:
                # should look at this list more
                sugg_str = suggestions[0].get("Text")
                curr_string += msg.text[prev_end:start] + sugg_str
                prev_end = end

        curr_string += msg.text[prev_end:]
        update.effective_message.reply_text(curr_string)
    else:
        update.effective_message.reply_text(
            "Reply to some message to get grammar corrected text!")


dispatcher.add_handler(CommandHandler("spell", spellcheck))
dispatcher.add_handler(CommandHandler(["tr", "tl"], gtrans, pass_args=True))

__help__ = """
 - /afk <reason>: mark yourself as AFK(Away From Keyboard)
 - brb <reason>: same as the afk command
 - /spell: while replying to a message, will reply with a grammar corrected version(ENGLISH ONLY)
 - /forbesify: Correct your punctuations better use the advanged spell module
 - /tr (language code) as reply to a long message.
 - /define <text>: Type the word or expression you want to search\nFor example /define Gay
 - /emotion: Type in reply to a message to check emotions (English Only)
 - /banme: ban yourself from a chat
 - /kickme: kicks yourself from a chat
 - /rules: get the rules for this chat
 - /markdownhelp: quick summary of how markdown works in telegram - can only be called in private chats
 - /report <reason> | @admin: reply to a message to report it to admins(non-admin only)
Ejemplo n.º 7
0
    filters = data.get("filters", {})
    for trigger in filters:
        sql.add_to_blacklist(chat_id, trigger)


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


def __chat_settings__(chat_id, user_id):
    cust_filters = sql.get_chat_triggers(chat_id)
    return "There are `{}` custom filters here.".format(len(cust_filters))


__mod_name__ = "Filters"

FILTER_HANDLER = CommandHandler("filter", filters)
STOP_HANDLER = CommandHandler("stop", stop_filter)
RMALLFILTER_HANDLER = CommandHandler("rmallfilter",
                                     rmall_filters,
                                     filters=Filters.group)
LIST_HANDLER = CommandHandler("filters", list_handlers, admin_ok=True)
CUST_FILTER_HANDLER = MessageHandler(
    CustomFilters.has_text & ~Filters.update.edited_message, reply_filter)

dispatcher.add_handler(FILTER_HANDLER)
dispatcher.add_handler(STOP_HANDLER)
dispatcher.add_handler(LIST_HANDLER)
dispatcher.add_handler(CUST_FILTER_HANDLER, HANDLER_GROUP)
dispatcher.add_handler(RMALLFILTER_HANDLER)
Ejemplo n.º 8
0
@run_async
@user_admin
def rhappy(update: Update, context: CallbackContext):
    message = update.effective_message
    rhappy = random.choice(reactionhappy)
    if message.reply_to_message:
        message.reply_to_message.reply_text(rhappy)
    else:
        message.reply_text(rhappy)


@run_async
@user_admin
def rangry(update: Update, context: CallbackContext):
    message = update.effective_message
    rangry = random.choice(reactionangry)
    if message.reply_to_message:
        message.reply_to_message.reply_text(rangry)
    else:
        message.reply_text(rangry)


REACT_HANDLER = CommandHandler("react", react)
RHAPPY_HANDLER = CommandHandler("happy", rhappy)
RANGRY_HANDLER = CommandHandler("amgery", rangry)

dispatcher.add_handler(REACT_HANDLER)
dispatcher.add_handler(RHAPPY_HANDLER)
dispatcher.add_handler(RANGRY_HANDLER)
Ejemplo n.º 9
0
            settypeflood))
    send_message(update.effective_message, text, parse_mode=ParseMode.MARKDOWN)
    return ""


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 enforcing to flood control."
    return "Antiflood has been set to`{}`.".format(limit)


__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)
Ejemplo n.º 10
0
SET_CLEAN_BLUE_TEXT_HANDLER = CommandHandler(
    "cleanbluetext", set_blue_text_must_click, pass_args=True
)
ADD_CLEAN_BLUE_TEXT_HANDLER = CommandHandler(
    "ignorecleanbluetext", add_bluetext_ignore, 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__ = "Anti-Spam 🚦"
Ejemplo n.º 11
0
__mod_name__ = "Memes 💢"

COPYPASTA_HANDLER = CommandHandler("copypasta", copypasta)
CLAPMOJI_HANDLER = CommandHandler("clapmoji", clapmoji)
BMOJI_HANDLER = CommandHandler("bmoji", bmoji)
OWO_HANDLER = CommandHandler("owo", owo)
STRETCH_HANDLER = CommandHandler("stretch", stretch)
VAPOR_HANDLER = CommandHandler("vapor", vapor, pass_args=True)
ZALGO_HANDLER = CommandHandler("zalgofy", zalgotext)
FORBES_HANDLER = CommandHandler("forbes", forbesify)
DEEPFRY_HANDLER = CommandHandler("deepfry", deepfryer)
SHOUT_HANDLER = CommandHandler("shout", shout, pass_args=True)
# FORBES_HANDLER = CommandHandler("forbesify", forbesify)
ANGRYMOJI_HANDLER = CommandHandler("angrymoji", angrymoji)
CRYMOJI_HANDLER = CommandHandler("crymoji", crymoji)

dispatcher.add_handler(ANGRYMOJI_HANDLER)
dispatcher.add_handler(CRYMOJI_HANDLER)
dispatcher.add_handler(COPYPASTA_HANDLER)
dispatcher.add_handler(CLAPMOJI_HANDLER)
dispatcher.add_handler(BMOJI_HANDLER)
dispatcher.add_handler(SHOUT_HANDLER)
dispatcher.add_handler(OWO_HANDLER)
# dispatcher.add_handler(FORBES_HANDLER)
dispatcher.add_handler(STRETCH_HANDLER)
dispatcher.add_handler(VAPOR_HANDLER)
dispatcher.add_handler(ZALGO_HANDLER)
dispatcher.add_handler(FORBES_HANDLER)
dispatcher.add_handler(DEEPFRY_HANDLER)
Ejemplo n.º 12
0
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 = CommandHandler("reverse",
                                 reverse,
                                 pass_args=True,
                                 admin_ok=True)

dispatcher.add_handler(REVERSE_HANDLER)
Ejemplo n.º 13
0
                                 ["5. Exchange Rate"])
        except KeyError:
            update.effective_message.reply_text("Currency Not Supported.")
            return
        new_cur_amount = round(orig_cur_amount * current_rate, 5)
        update.effective_message.reply_text(
            f"{orig_cur_amount} {orig_cur} = {new_cur_amount} {new_cur}")

    elif len(args) == 1:
        update.effective_message.reply_text(__help__,
                                            parse_mode=ParseMode.MARKDOWN)

    else:
        update.effective_message.reply_text(
            f"*Invalid Args!!:* Required 3 But Passed {len(args) -1}",
            parse_mode=ParseMode.MARKDOWN,
        )


CONVERTER_HANDLER = CommandHandler("cash", convert)

dispatcher.add_handler(CONVERTER_HANDLER)

__command_list__ = ["cash"]
__handlers__ = [CONVERTER_HANDLER]
__help__ = """
 - /cash : currency converter
 example syntax: /cash 1 USD INR
"""
__mod_name__ = "Currency 💰"
Ejemplo n.º 14
0
FACTOR_HANDLER = CommandHandler("factor", factor)
DERIVE_HANDLER = CommandHandler("derive", derive)
INTEGRATE_HANDLER = CommandHandler("integrate", integrate)
ZEROES_HANDLER = CommandHandler("zeroes", zeroes)
TANGENT_HANDLER = CommandHandler("tangent", tangent)
AREA_HANDLER = CommandHandler("area", area)
COS_HANDLER = CommandHandler("cos", cos)
SIN_HANDLER = CommandHandler("sin", sin)
TAN_HANDLER = CommandHandler("tan", tan)
ARCCOS_HANDLER = CommandHandler("arccos", arccos)
ARCSIN_HANDLER = CommandHandler("arcsin", arcsin)
ARCTAN_HANDLER = CommandHandler("arctan", arctan)
ABS_HANDLER = CommandHandler("abs", abs)
LOG_HANDLER = CommandHandler("log", log)

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)
Ejemplo n.º 15
0
                ses_id = str(ses.id)
                expires = str(ses.expires)
                sql.set_ses(chat_id, ses_id, expires)
                sesh, exp = sql.get_ses(chat_id)
        except ValueError:
            pass
        try:
            bot.send_chat_action(chat_id, action="typing")
            rep = api_client.think_thought(sesh, query)
            sleep(0.3)
            msg.reply_text(rep, timeout=60)
        except CFError as e:
            bot.send_message(OWNER_ID,
                             f"Chatbot error: {e} occurred in {chat_id}!")


ADD_CHAT_HANDLER = CommandHandler("addchat", add_chat)
REMOVE_CHAT_HANDLER = CommandHandler("rmchat", remove_chat)
CHATBOT_HANDLER = MessageHandler(
    Filters.text
    & (~Filters.regex(r"^#[^\s]+") & ~Filters.regex(r"^!")
       & ~Filters.regex(r"^\/")),
    chatbot,
)

dispatcher.add_handler(ADD_CHAT_HANDLER)
dispatcher.add_handler(REMOVE_CHAT_HANDLER)
dispatcher.add_handler(CHATBOT_HANDLER)

__mod_name__ = "Chatbot"
Ejemplo n.º 16
0
    num_chats = sql.get_user_num_chats(user_id)
    return """I've seen them in <code>{}</code> chats in total.""".format(
        num_chats)


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


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


__mod_name__ = "Users"

BROADCAST_HANDLER = CommandHandler("broadcast",
                                   broadcast,
                                   filters=Filters.user(OWNER_ID))
USER_HANDLER = MessageHandler(Filters.all & Filters.group, log_user)
CHATLIST_HANDLER = CommandHandler("chatlist",
                                  chats,
                                  filters=Filters.user(OWNER_ID))
CHAT_CHECKER_HANDLER = MessageHandler(Filters.all & Filters.group,
                                      chat_checker)

dispatcher.add_handler(USER_HANDLER, USERS_GROUP)
dispatcher.add_handler(BROADCAST_HANDLER)
dispatcher.add_handler(CHATLIST_HANDLER)
dispatcher.add_handler(CHAT_CHECKER_HANDLER, CHAT_GROUP)
Ejemplo n.º 17
0
            )
            query.answer("тЪая╕П Failed to delete message!")


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 "This chat is setup to send user reports to admins, via /report and @admin: `{}`".format(
        sql.chat_should_report(chat_id))


def __user_settings__(user_id):
    return "You receive reports from chats you're admin in: `{}`.\nToggle this with /reports in PM.".format(
        sql.user_should_report(user_id))


__mod_name__ = "Reporting"

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)
Ejemplo n.º 18
0
    "You should try playing snake and ladders, with real snakes and no ladders.",
    "Dance naked on a couple of HT wires.",
    "Active Volcano is the best swimming pool for you.",
    "You should try hot bath in a volcano.",
    "Try to spend one day in a coffin and it will be yours forever.",
    "Hit Uranium with a slow moving neutron in your presence. It will be a worthwhile experience.",
    "You can be the first person to step on sun. Have a try.",
    "People like you are the reason we have middle fingers.",
    "When your mom dropped you off at the school, she got a ticket for littering.",
    "You’re so ugly that when you cry, the tears roll down the back of your head…just to avoid your face.",
    "If you’re talking behind my back then you’re in a perfect position to kiss my a**!.",
    "Stupidity is not a crime so you are free to go.",
)


@run_async
@user_admin
def insult(update, context):
    # Bot typing before send messages
    bot.sendChatAction(update.effective_chat.id, "typing")
    message = update.effective_message
    if message.reply_to_message:
        message.reply_to_message.reply_text(random.choice(SFW_STRINGS))
    else:
        message.reply_text(random.choice(SFW_STRINGS))


INSULT_HANDLER = CommandHandler("insult", insult)

dispatcher.add_handler(INSULT_HANDLER)
Ejemplo n.º 19
0
            elapsed_time = time.time() - float(etime)
            final = time.strftime("%Hh: %Mm: %Ss", time.gmtime(elapsed_time))

            if int(userc_id) == int(user_id):
                return
            res = "*{} is AFK !*\n\n*Last seen*: {}".format(fst_name, final)
            update.effective_message.reply_text(res,
                                                parse_mode=ParseMode.MARKDOWN)
        else:
            etime = user.start_time
            elapsed_time = time.time() - float(etime)
            final = time.strftime("%Hh: %Mm: %Ss", time.gmtime(elapsed_time))

            if int(userc_id) == int(user_id):
                return
            res = "*{} is AFK !*\n\n*Reason*: {}\n\n*Last seen*: {}".format(
                fst_name, user.reason, final)
            update.effective_message.reply_text(res,
                                                parse_mode=ParseMode.MARKDOWN)


AFK_HANDLER = CommandHandler("afk", 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(NO_AFK_HANDLER, AFK_GROUP)
dispatcher.add_handler(AFK_REPLY_HANDLER, AFK_REPLY_GROUP)

__mod_name__ = "AFK"
Ejemplo n.º 20
0
    if reason:
        log += "\n<b>Reason:</b> {}".format(reason)

    return log


__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 = CommandHandler("kickme", kickme, filters=Filters.group)
BANME_HANDLER = CommandHandler("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)
Ejemplo n.º 21
0
    return f"• {sql.num_chats()} chats have rules set."


def __import_data__(chat_id, data):
    # set chat rules
    rules = data.get("info", {}).get("rules", "")
    sql.set_rules(chat_id, rules)


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 f"This chat has had it's rules set: `{bool(sql.get_rules(chat_id))}`"


__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)
Ejemplo n.º 22
0
@run_async
@spamcheck
@user_admin
def gps(update: Update, context):
    message = update.effective_message
    args = context.args
    if len(args) == 0:
        update.effective_message.reply_text(
            "That was a funny joke, but no really, put in a location")
    try:
        geolocator = Nominatim(user_agent="SkittBot")
        location = " ".join(args)
        geoloc = geolocator.geocode(location)
        chat_id = update.effective_chat.id
        lon = geoloc.longitude
        lat = geoloc.latitude
        the_loc = Location(lon, lat)
        gm = "https://www.google.com/maps/search/{},{}".format(lat, lon)
        context.bot.send_location(chat_id, location=the_loc)
        update.message.reply_text(
            "Open with: [Google Maps]({})".format(gm),
            parse_mode=ParseMode.MARKDOWN,
            disable_web_page_preview=True,
        )
    except AttributeError:
        update.message.reply_text("I can't find that")


GPS_HANDLER = CommandHandler("gps", gps, pass_args=True)
dispatcher.add_handler(GPS_HANDLER)
Ejemplo n.º 23
0
        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 ""


__mod_name__ = "Muting"

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)

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