Пример #1
0
def start(update: Update, context: CallbackContext):
    if update.effective_chat.type == "private":
        args = context.args
        if len(args) >= 1:
            if args[0].lower() == "help":
                send_help(update.effective_chat.id, HELP_STRINGS)
            elif args[0].lower() == "markdownhelp":
                IMPORTED["extras"].markdown_help_sender(update)
            elif args[0].lower() == "nations":
                IMPORTED["nations"].send_nations(update)
            elif args[0].lower().startswith("stngs_"):
                match = re.match("stngs_(.*)", args[0].lower())
                chat = dispatcher.bot.getChat(match.group(1))

                if is_user_admin(chat, update.effective_user.id):
                    send_settings(
                        match.group(1), update.effective_user.id, False)
                else:
                    send_settings(
                        match.group(1), update.effective_user.id, True)

            elif args[0][1:].isdigit() and "rules" in IMPORTED:
                IMPORTED["rules"].send_rules(update, args[0], from_pm=True)

        else:
            first_name = update.effective_user.first_name
            update.effective_message.reply_photo(LYNDA_IMG,
                PM_START_TEXT.format(escape_markdown(first_name), escape_markdown(bot.first_name), OWNER_ID),
                parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text="Add Chiyo To Your Group",
                                                                       url="t.me/{}?startgroup=true".format(bot.username))]]))
    else:
        update.effective_message.reply_text("Heya Am *Chiyo*!")
Пример #2
0
def check_user(user_id: int, context: CallbackContext,
               chat: Chat) -> Optional[str]:
    bot = context.bot
    if not user_id:
        reply = "You don't seem to be referring to a user."
        return reply

    try:
        member = chat.get_member(user_id)
    except BadRequest as excp:
        if excp.message == "User not found":
            reply = "I can't seem to find this user"
            return reply
        else:
            raise

    if user_id == bot.id:
        reply = "I'm not gonna MUTE myself, How high are you?"
        return reply

    if is_user_admin(chat, user_id, member) or user_id in SARDEGNA_USERS:
        reply = "I really wish I could mute admins...Perhaps a Punch?"
        return reply

    return None
Пример #3
0
 def check_update(self, update):
     return super().check_update(update) and not (
         sql.is_restr_locked(
             update.effective_chat.id,
             'messages') and not is_user_admin(
             update.effective_chat,
             update.effective_user.id))
Пример #4
0
def get_settings(update: Update, context: CallbackContext):
    """Getting Settings String"""
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    msg = update.effective_message  # type: Optional[Message]
    msg.text.split(None, 1)

    # ONLY send settings in PM
    if chat.type != chat.PRIVATE:
        if is_user_admin(chat, user.id):
            text = "Click here to get this chat's settings, as well as yours."
            msg.reply_text(
                text,
                reply_markup=InlineKeyboardMarkup([[
                    InlineKeyboardButton(
                        text="Settings",
                        url="t.me/{}?start=stngs_{}".format(
                            context.bot.username, chat.id),
                    )
                ]]),
            )
        else:
            text = "Click here to check your settings."

    else:
        send_settings(chat.id, user.id, True)
Пример #5
0
def start(update: Update, context: CallbackContext):
    if update.effective_chat.type == "private":
        args = context.args
        if len(args) >= 1:
            if args[0].lower() == "help":
                send_help(update.effective_chat.id, HELP_STRINGS)
            elif args[0].lower() == "markdownhelp":
                IMPORTED["extras"].markdown_help_sender(update)
            elif args[0].lower() == "nations":
                IMPORTED["nations"].send_nations(update)
            elif args[0].lower().startswith("stngs_"):
                match = re.match("stngs_(.*)", args[0].lower())
                chat = dispatcher.bot.getChat(match.group(1))

                if is_user_admin(chat, update.effective_user.id):
                    send_settings(match.group(1), update.effective_user.id,
                                  False)
                else:
                    send_settings(match.group(1), update.effective_user.id,
                                  True)

            elif args[0][1:].isdigit() and "rules" in IMPORTED:
                IMPORTED["rules"].send_rules(update, args[0], from_pm=True)

        else:
            first_name = update.effective_user.first_name
            buttons = InlineKeyboardMarkup([
                [
                    InlineKeyboardButton(
                        text="👥 Add Lynda to your group",
                        url="https://t.me/LyndaRobot?startgroup=new",
                    )
                ],
                [
                    InlineKeyboardButton(text="🙋 Support Group",
                                         url="https://t.me/LyndaEagleSupport"),
                    InlineKeyboardButton(text="🚫 Global Logs",
                                         url="https://t.me/LyndaGLogs"),
                ],
                [
                    InlineKeyboardButton(
                        text="❔ Help",
                        url="https://t.me/LyndaRobot?start=help"),
                    InlineKeyboardButton(text="🔔 Update Channel",
                                         url="https://t.me/LyndaUpdateLogs"),
                ],
            ])
            update.effective_message.reply_photo(
                LYNDA_IMG,
                PM_START_TEXT.format(
                    escape_markdown(first_name),
                    escape_markdown(context.bot.first_name),
                    OWNER_ID,
                ),
                parse_mode=ParseMode.MARKDOWN,
                reply_markup=buttons,
            )
    else:
        update.effective_message.reply_text("Hola!")
Пример #6
0
def start(bot: Bot, update: Update, args: List[str]):
    """Triggers start command in pm and in groupchats"""
    message = update.effective_message
    if update.effective_chat.type == "private":
        if len(args) >= 1:
            if args[0].lower() == "help":
                send_help(update.effective_chat.id, HELP_STRINGS)
            elif args[0].lower() == "Nations":
                IMPORTED["Nations"].send_Nations(update)
            elif args[0].lower().startswith("stngs_"):
                match = re.match("stngs_(.*)", args[0].lower())
                chat = dispatcher.bot.getChat(match.group(1))

                if is_user_admin(chat, update.effective_user.id):
                    send_settings(match.group(1), update.effective_user.id,
                                  False)
                else:
                    send_settings(match.group(1), update.effective_user.id,
                                  True)

            elif args[0][1:].isdigit() and "rules" in IMPORTED:
                IMPORTED["rules"].send_rules(update, args[0], from_pm=True)

        else:
            first_name = update.effective_user.first_name
            buttons = InlineKeyboardMarkup(
                [[
                    InlineKeyboardButton(
                        text="👥 Add Me To Your Groups",
                        url="https://t.me/DadOfHacking_Bot?startgroup=new")
                ],
                 [
                     InlineKeyboardButton(text="Support Group",
                                          url="https://t.me/IPCA_BOT_Support"),
                     InlineKeyboardButton(text="🚫 Global Logs",
                                          url="https://t.me/DadOfHackingGLogs")
                 ],
                 [
                     InlineKeyboardButton(text="❔ Help",
                                          callback_data="help_back"),
                     InlineKeyboardButton(
                         text="🔔 Update Channel",
                         url="https://t.me/DadOfHackingUpdates")
                 ]])
            message.reply_photo(LYNDA_IMG,
                                PM_START_TEXT.format(
                                    escape_markdown(first_name),
                                    escape_markdown(bot.first_name), OWNER_ID),
                                parse_mode=ParseMode.MARKDOWN,
                                reply_markup=buttons)
    else:
        message.reply_text(
            "Yup. I'm Alive. PM Me If You Have Any Questions On How To Use Me."
        )
Пример #7
0
def kickme(bot: Bot, update: Update):
    user_id = update.effective_message.from_user.id
    if is_user_admin(update.effective_chat, user_id):
        update.effective_message.reply_text("I wish I could... but you're an admin.")
        return

    res = update.effective_chat.unban_member(user_id)  # unban on current user = kick
    if res:
        update.effective_message.reply_text("No problem.")
    else:
        update.effective_message.reply_text("Huh? I can't :/")
Пример #8
0
def start(bot: Bot, update: Update, args: List[str]):
    """Triggers start command in pm and in groupchats"""
    message = update.effective_message
    if update.effective_chat.type == "private":
        if len(args) >= 1:
            if args[0].lower() == "help":
                send_help(update.effective_chat.id, HELP_STRINGS)
            elif args[0].lower() == "nations":
                IMPORTED["nations"].send_nations(update)
            elif args[0].lower().startswith("stngs_"):
                match = re.match("stngs_(.*)", args[0].lower())
                chat = dispatcher.bot.getChat(match.group(1))

                if is_user_admin(chat, update.effective_user.id):
                    send_settings(match.group(1), update.effective_user.id,
                                  False)
                else:
                    send_settings(match.group(1), update.effective_user.id,
                                  True)

            elif args[0][1:].isdigit() and "rules" in IMPORTED:
                IMPORTED["rules"].send_rules(update, args[0], from_pm=True)

        else:
            first_name = update.effective_user.first_name
            buttons = InlineKeyboardMarkup([
                [
                    InlineKeyboardButton(
                        text="📱 Rent Chizuru to your group",
                        url="https://t.me/ChizuruChanBot?startgroup=new")
                ],
                [
                    InlineKeyboardButton(
                        text="🙋 Support Group",
                        url="https://t.me/joinchat/MCPZ_li6GFtEIh5OcvOOsA"),
                    InlineKeyboardButton(text="🚫 Global Logs",
                                         url="http://t.me/ChizuruxRukaGbanLog")
                ],
                [
                    InlineKeyboardButton(text="❔ Help",
                                         callback_data="help_back"),
                    InlineKeyboardButton(text="🔔 Update Channel",
                                         url="https://t.me/LyndaUpdateLogs")
                ]
            ])
            message.reply_photo(LYNDA_IMG,
                                PM_START_TEXT.format(
                                    escape_markdown(first_name),
                                    escape_markdown(bot.first_name), OWNER_ID),
                                parse_mode=ParseMode.MARKDOWN,
                                reply_markup=buttons)
    else:
        message.reply_text("Hola!")
Пример #9
0
def enforce_gban(bot: Bot, update: Update):
    # Not using @restrict handler to avoid spamming - just ignore if cant gban.
    if sql.does_chat_gban(
            update.effective_chat.id) and update.effective_chat.get_member(
            bot.id).can_restrict_members:
        user = update.effective_user
        chat = update.effective_chat
        msg = update.effective_message

        if user and not is_user_admin(chat, user.id):
            check_and_ban(update, user.id)

        if msg.new_chat_members:
            new_members = update.effective_message.new_chat_members
            for mem in new_members:
                check_and_ban(update, mem.id)

        if msg.reply_to_message:
            user = msg.reply_to_message.from_user
            if user and not is_user_admin(chat, user.id):
                check_and_ban(update, user.id, should_message=False)
Пример #10
0
def unlock(update: Update, context: CallbackContext) -> str:
    bot = context.bot
    chat = update.effective_chat
    message = update.effective_message

    if is_user_admin(chat, message.from_user.id):
        args = context.args
        if len(args) >= 1:
            user = update.effective_user
            if args[0] in LOCK_TYPES:
                sql.update_lock(chat.id, args[0], locked=False)
                message.reply_text(f"Unlocked {args[0]} for everyone!")
                return (
                    f"<b>{html.escape(chat.title)}:</b>\n"
                    f"#UNLOCK\n"
                    f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                    f"Unlocked <code>{args[0]}</code>.")

            elif args[0] in RESTRICTION_TYPES:
                sql.update_restriction(chat.id, args[0], locked=False)
                """
                #members = users_sql.get_chat_members(chat.id)
                if args[0] == "messages":
                    chat.set_permissions(can_send_messages=True)

                elif args[0] == "media":
                    chat.set_permissions(can_send_media_messages=True)

                elif args[0] == "other":
                    chat.set_permissions(can_send_other_messages=True)

                elif args[0] == "previews":
                    chat.set_permissions(can_add_web_page_previews=True)

                elif args[0] == "all":
                    chat.set_permissions(can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True, can_send_polls=True)
                """
                message.reply_text("Unlocked {} for everyone!".format(args[0]))

                return (
                    f"<b>{html.escape(chat.title)}:</b>\n"
                    f"#UNLOCK\n"
                    f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                    f"Unlocked <code>{args[0]}</code>.")
            else:
                message.reply_text(
                    "What are you trying to unlock...? Try /locktypes for the list of lockables"
                )

        else:
            bot.sendMessage(chat.id, "What are you trying to unlock...?")

    return ""
Пример #11
0
def slap(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
    chat = update.effective_chat

    reply_text = message.reply_to_message.reply_text if message.reply_to_message else message.reply_text

    curr_user = html.escape(message.from_user.first_name)
    user_id = extract_user(message, args)

    if user_id == bot.id:
        temp = random.choice(fun_strings.SLAP_LYNDA_TEMPLATES)

        if isinstance(temp, list):
            if temp[2] == "tmute":
                if is_user_admin(chat, message.from_user.id):
                    reply_text(temp[1])
                    return

                mutetime = int(time.time() + 60)
                bot.restrict_chat_member(
                    chat.id,
                    message.from_user.id,
                    until_date=mutetime,
                    can_send_messages=False)
            reply_text(temp[0])
        else:
            reply_text(temp)
        return

    if user_id:

        slapped_user = bot.get_chat(user_id)
        user1 = curr_user
        user2 = html.escape(slapped_user.first_name)

    else:
        user1 = bot.first_name
        user2 = curr_user

    temp = random.choice(fun_strings.SLAP_TEMPLATES)
    item = random.choice(fun_strings.ITEMS)
    hit = random.choice(fun_strings.HIT)
    throw = random.choice(fun_strings.THROW)

    reply = temp.format(
        user1=user1,
        user2=user2,
        item=item,
        hits=hit,
        throws=throw)

    reply_text(reply, parse_mode=ParseMode.HTML)
Пример #12
0
def enforce_gban(update: Update, context: CallbackContext):
    bot = context.bot
    # Not using @restrict handler to avoid spamming - just ignore if cant gban.
    if (not sql.does_chat_gban(update.effective_chat.id) or
            not update.effective_chat.get_member(bot.id).can_restrict_members):
        return
    user = update.effective_user
    chat = update.effective_chat
    msg = update.effective_message

    if user and not is_user_admin(chat, user.id):
        check_and_ban(update, user.id)

    if msg.new_chat_members:
        new_members = update.effective_message.new_chat_members
        for mem in new_members:
            check_and_ban(update, mem.id)

    if msg.reply_to_message:
        user = msg.reply_to_message.from_user
        if user and not is_user_admin(chat, user.id):
            check_and_ban(update, user.id, should_message=False)
Пример #13
0
def banme(update: Update, context: CallbackContext):
    message = update.effective_message
    if is_user_admin(update.effective_chat, update.effective_message.from_user.id):
        update.effective_message.reply_text("Ya lu gabisa ban admin bego.")
        return
    try:
        context.bot.kick_chat_member(update.effective_chat.id, update.effective_message.from_user.id)
        context.bot.send_sticker(update.effective_chat.id, BAN_STICKER)  # banhammer marie sticker
        response_message = "Kebanyakan di ban c*k"
    except Exception as e:
        print(e)
        response_message = "Ohno! something is not right please contact @LyndaEagleSupport"
    message.reply_text(response_message)
Пример #14
0
def banme(bot: Bot, update: Update):
    message = update.effective_message
    if is_user_admin(update.effective_chat,
                     update.effective_message.from_user.id):
        update.effective_message.reply_text("Can't ban admins as you can see.")
        return
    try:
        bot.kick_chat_member(update.effective_chat.id,
                             update.effective_message.from_user.id)
        bot.send_sticker(update.effective_chat.id,
                         BAN_STICKER)  # banhammer marie sticker
        response_message = "lmao have a load of ban UwU!"
    except Exception:
        response_message = "Ohno! something is not right please contact @LyndaEagleSupport"
    message.reply_text(response_message)
Пример #15
0
def check_flood(update: Update, context: CallbackContext) -> str:
    user = update.effective_user
    chat = update.effective_chat
    msg = update.effective_message
    log_message = ""

    if not user:  # ignore channels
        return log_message

    # ignore admins and whitelists
    if (is_user_admin(chat, user.id) or user.id in WHITELIST_USERS
            or user.id in SARDEGNA_USERS):
        sql.update_flood(chat.id, None)
        return log_message

    should_ban = sql.update_flood(chat.id, user.id)
    if not should_ban:
        return log_message

    try:
        context.bot.restrict_chat_member(chat.id,
                                         user.id,
                                         can_send_messages=False)
        context.bot.send_message(
            chat.id,
            f"*mutes {mention_html(user.id, user.first_name)} permanently*\nStop flooding the group!",
            parse_mode=ParseMode.HTML,
        )
        log_message = (
            f"<b>{html.escape(chat.title)}:</b>\n"
            f"#MUTED\n"
            f"<b>User:</b> {mention_html(user.id, user.first_name)}\n"
            f"Flooded the group.\nMuted until an admin unmutes")

        return log_message

    except BadRequest:
        msg.reply_text(
            "I can't kick people here, give me permissions first! Until then, I'll disable antiflood."
        )
        sql.set_flood(chat.id, 0)
        log_message = (
            "<b>{chat.title}:</b>\n"
            "#INFO\n"
            "Don't have kick permissions, so automatically disabled antiflood."
        )

        return log_message
Пример #16
0
def banme(update: Update, context: CallbackContext):
    message = update.effective_message
    if is_user_admin(update.effective_chat,
                     update.effective_message.from_user.id):
        update.effective_message.reply_text("Can't ban admins as you can see.")
        return
    try:
        context.bot.kick_chat_member(update.effective_chat.id,
                                     update.effective_message.from_user.id)
        context.bot.send_sticker(update.effective_chat.id,
                                 BAN_STICKER)  # banhammer marie sticker
        response_message = "lmao have a load of ban UwU!"
    except Exception as e:
        print(e)
        response_message = "Ohno! something is not right please contact @EagleUnions"
    message.reply_text(response_message)
Пример #17
0
        def check_update(self, update):
            chat = update.effective_chat
            user = update.effective_user

            if super().check_update(update):

                # Should be safe since check_update passed.
                command = update.effective_message.text_html.split(
                    None, 1)[0][1:].split('@')[0]

                # disabled, admincmd, user admin
                if sql.is_command_disabled(chat.id, command):
                    if command in ADMIN_CMDS and is_user_admin(chat, user.id):
                        return True

                # not disabled
                else:
                    return True
Пример #18
0
        def check_update(self, update):
            if not isinstance(update, Update) or not update.effective_message:
                return
            message = update.effective_message

            if message.text and len(message.text) > 1:
                fst_word = message.text.split(None, 1)[0]
                if len(fst_word) > 1 and any(
                        fst_word.startswith(start) for start in CMD_STARTERS):
                    args = message.text.split()[1:]
                    command = fst_word[1:].split("@")
                    command.append(message.bot.username)

                    if (command[0].lower() not in self.command
                            or command[1].lower() !=
                            message.bot.username.lower()):
                        return None

                    filter_result = self.filters(update)
                    if filter_result:
                        chat = update.effective_chat
                        user = update.effective_user
                        # disabled, admincmd, user admin
                        if sql.is_command_disabled(chat.id,
                                                   command[0].lower()):
                            # check if command was disabled
                            is_disabled = command[
                                0] in ADMIN_CMDS and is_user_admin(
                                    chat, user.id)
                            if not is_disabled:
                                return None
                            else:
                                return args, filter_result

                        return args, filter_result
                    else:
                        return False
Пример #19
0
def warn(user: User,
         chat: Chat,
         reason: str,
         message: Message,
         warner: User = None) -> str:
    if is_user_admin(chat, user.id):
        # message.reply_text("Damn admins, They are too far to be One Punched!")
        return

    if user.id in SARDEGNA_USERS:
        if warner:
            message.reply_text("Sardegnas cant be warned.")
        else:
            message.reply_text(
                "Sardegna triggered an auto warn filter!\n I can't warn Sardegnas but they should avoid abusing this."
            )
        return

    if user.id in WHITELIST_USERS:
        if warner:
            message.reply_text("Neptunia Nations are warn immune.")
        else:
            message.reply_text(
                "Neptunia Nation triggered an auto warn filter!\n I can't warn Neptunians but they should avoid abusing this."
            )
        return

    if warner:
        warner_tag = mention_html(warner.id, warner.first_name)
    else:
        warner_tag = "Automated warn filter."

    limit, soft_warn = sql.get_warn_setting(chat.id)
    num_warns, reasons = sql.warn_user(user.id, chat.id, reason)
    if num_warns >= limit:
        sql.reset_warns(user.id, chat.id)
        if soft_warn:  # punch
            chat.unban_member(user.id)
            reply = f"{limit} warnings, *Punches {mention_html(user.id, user.first_name)} with a normal punch!* "

        else:  # ban
            chat.kick_member(user.id)
            reply = f"{limit} warnings, *Punches {mention_html(user.id, user.first_name)} with a Serious Punch* "

        for warn_reason in reasons:
            reply += f"\n - {html.escape(warn_reason)}"

        message.bot.send_sticker(chat.id, BAN_STICKER)  # Lynda's sticker
        keyboard = []
        log_reason = (
            f"<b>{html.escape(chat.title)}:</b>\n"
            f"#WARN_BAN\n"
            f"<b>Admin:</b> {warner_tag}\n"
            f"<b>User:</b> {mention_html(user.id, user.first_name)}\n"
            f"<b>Reason:</b> {reason}\n"
            f"<b>Counts:</b> <code>{num_warns}/{limit}</code>")

    else:
        keyboard = InlineKeyboardMarkup([{
            InlineKeyboardButton("Remove warn",
                                 callback_data="rm_warn({})".format(user.id))
        }])

        reply = f"{mention_html(user.id, user.first_name)} has {num_warns}/{limit} warnings... watch out!"
        if reason:
            reply += f"\nReason for last warn:\n{html.escape(reason)}"

        log_reason = (
            f"<b>{html.escape(chat.title)}:</b>\n"
            f"#WARN\n"
            f"<b>Admin:</b> {warner_tag}\n"
            f"<b>User:</b> {mention_html(user.id, user.first_name)}\n"
            f"<b>Reason:</b> {reason}\n"
            f"<b>Counts:</b> <code>{num_warns}/{limit}</code>")

    try:
        message.reply_text(reply,
                           reply_markup=keyboard,
                           parse_mode=ParseMode.HTML)
    except BadRequest as excp:
        if excp.message == "Reply message not found":
            # Do not reply
            message.reply_text(reply,
                               reply_markup=keyboard,
                               parse_mode=ParseMode.HTML,
                               quote=False)
        else:
            raise
    return log_reason