def mute(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] user_id = extract_user(message, args) if not user_id: message.reply_text("Dovrai o darmi un nome utente per mutarlo o rispondere a qualcuno che deve essere mutato.") return "" if user_id == bot.id: message.reply_text("Non mi muterò!") return "" member = chat.get_member(int(user_id)) if member: if is_user_admin(chat, user_id, member=member): message.reply_text("Ho paura di non poter impedire a un amministratore di parlare!") elif member.can_send_messages is None or member.can_send_messages: bot.restrict_chat_member(chat.id, user_id, can_send_messages=False) message.reply_text("Muted!") return "<b>{}:</b>" \ "\n#MUTE" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(member.user.id, member.user.first_name)) else: message.reply_text("Questo utente è già in muto!") else: message.reply_text("Questo utente non esiste in questa chat!") return ""
def start(bot: Bot, update: Update, args: List[str]): 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() == "disasters": IMPORTED["disasters"].send_disasters(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( TECHNO_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="⤵️🤝HELP🤝⤵️", callback_data="help_back".format(bot.username)), InlineKeyboardButton(text="👩💻CREATOR👩💻", url=f"t.me/Mr_Purushottam")], [InlineKeyboardButton(text="⤴️TAKE ME TO YOUR GROUP⤴️", url="t.me/{}?startgroup=true".format(bot.username)), InlineKeyboardButton(text="👩💻SAURCE CODE IN BIO🥺", url="https://instagram.com/mr_purushottam_m/") ]])) else: update.effective_message.reply_text("Hello Mr / Mrs Who are you & Why are you starting me ?? 🥺😉, I am Already ONline")
def check_flood(bot: Bot, update: Update) -> str: user = update.effective_user # type: Optional[User] chat = update.effective_chat # type: Optional[Chat] msg = update.effective_message # type: Optional[Message] if not user: # ignore channels return "" # ignore admins if is_user_admin(chat, user.id): sql.update_flood(chat.id, None) return "" should_ban = sql.update_flood(chat.id, user.id) if not should_ban: return "" try: chat.kick_member(user.id) msg.reply_text( "dont disturb others you are No need for this group anymore...") return "<b>{}:</b>" \ "\n#BANNED" \ "\n<b>User:</b> {}" \ "\nFlooded the group.".format(html.escape(chat.title), mention_html(user.id, user.first_name)) except BadRequest: msg.reply_text( "You cannot use this service as long as you do not give me Permissions." ) sql.set_flood(chat.id, 0) return "<b>{}:</b>" \ "\n#INFO" \ "\nDon't have kick permissions, so automatically disabled antiflood.".format(chat.title)
def start(bot: Bot, update: Update, args: List[str]): print("Start") chat = update.effective_chat # type: Optional[Chat] query = update.callback_query if update.effective_chat.type == "private": if len(args) >= 1: if args[0].lower() == "help": send_help(update.effective_chat.id, ( chat.id, "send-help" ).format( dispatcher.bot.first_name, "" if not ALLOW_EXCL else tld( chat.id, "\nAll commands can either be used with `/` or `!`.\n") )) 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, user=False) else: send_settings(match.group(1), update.effective_user.id, user=True) elif args[0][1:].isdigit() and "rules" in IMPORTED: IMPORTED["rules"].send_rules(update, args[0], from_pm=True) else: send_start(bot, update) else: update.effective_message.reply_text( "വേറെ ഒരു പണിയും ഇല്ലേ നിനക്ക് ഒന്നും...😎")
def get_settings(update: Update, context: CallbackContext): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] msg = update.effective_message # type: Optional[Message] # 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)
def mute(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] user_id = extract_user(message, args) if not user_id: message.reply_text("You'll need to either give me a username to mute, or reply to someone to be muted.") return "" if user_id == bot.id: message.reply_text("I'm not muting myself!") return "" member = chat.get_member(int(user_id)) if member: if is_user_admin(chat, user_id, member=member): message.reply_text("Afraid I can't stop an admin from talking!") elif member.can_send_messages is None or member.can_send_messages: bot.restrict_chat_member(chat.id, user_id, can_send_messages=False) message.reply_text("👍🏻 muted! 🤐") return "<b>{}:</b>" \ "\n#MUTE" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(member.user.id, member.user.first_name)) else: message.reply_text("This user is already muted!") else: message.reply_text("This user isn't in the chat!") return ""
def check_flood(bot: Bot, update: Update) -> str: user = update.effective_user # type: Optional[User] chat = update.effective_chat # type: Optional[Chat] msg = update.effective_message # type: Optional[Message] if not user: # ignore channels return "" # ignore admins if is_user_admin(chat, user.id): sql.update_flood(chat.id, None) return "" should_ban = sql.update_flood(chat.id, user.id) if not should_ban: return "" try: chat.kick_member(user.id) msg.reply_text( "നിർത്താത്ത മെസേജ് ഇട്ടാൽ....അത് കീരികാടന് ശല്യം ആവും കേട്ടോ!.") return "<b>{}:</b>" \ "\n#BANNED" \ "\n<b>User:</b> {}" \ "\nFlooded the group.".format(html.escape(chat.title), mention_html(user.id, user.first_name)) except BadRequest: msg.reply_text( "നിങ്ങൾ എനിക്ക് Permissions തരാത്ത കാലത്തോളം ഈ സേവനം നിങ്ങൾക്ക് ഉപയോഗിക്കാൻ കഴിയില്ല." ) sql.set_flood(chat.id, 0) return "<b>{}:</b>" \ "\n#INFO" \ "\nDon't have kick permissions, so automatically disabled antiflood.".format(chat.title)
def mute(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] user_id = extract_user(message, args) if not user_id: message.reply_text("а∂±аЈТаЈБаЈКаЈБа∂∂аЈКа∂ѓ а∂ЪаЈТа∂їаЈУа∂Є аЈГа∂≥аЈДаЈП а∂Фа∂∂а∂І а∂іа∂їаЈТаЈБаЈУа∂ља∂Ъ а∂±аЈПа∂Єа∂Їа∂ЪаЈК а∂ља∂∂аЈП а∂ѓаЈУа∂Єа∂І аЈДаЈЭ а∂±аЈТаЈБаЈКаЈБа∂∂аЈКа∂ѓ а∂ЪаЈТа∂їаЈУа∂Єа∂І а∂Їа∂ЄаЈЩа∂ЪаЈФа∂І а∂іаЈТаЈЕаЈТа∂≠аЈФа∂їаЈФ а∂ѓаЈУа∂Єа∂І а∂Фа∂∂а∂І а∂ЕаЈАаЈБаЈКвАНа∂Ї аЈАа∂±аЈФ а∂За∂≠.") return "" if user_id == bot.id: message.reply_text("а∂Єа∂Є а∂ЄаЈП а∂ЬаЈРа∂±а∂Є а∂Ъа∂≠аЈП а∂Ъа∂їа∂±аЈКа∂±аЈЪ а∂±аЈРаЈДаЈР!") return "" member = chat.get_member(int(user_id)) if member: if is_user_admin(chat, user_id, member=member): message.reply_text("а∂∂аЈТа∂ЇаЈЩа∂±аЈК а∂Єа∂І а∂іа∂їаЈТа∂іаЈПа∂ља∂Ъа∂ЇаЈЩа∂ЪаЈФ а∂Ъа∂≠аЈП а∂ЪаЈТа∂їаЈУа∂Є а∂±а∂≠а∂ї а∂ЪаЈЕ а∂±аЈЬаЈДаЈРа∂Ъ!") elif member.can_send_messages is None or member.can_send_messages: bot.restrict_chat_member(chat.id, user_id, can_send_messages=False) message.reply_text("рЯСНрЯПї а∂±аЈТаЈБаЈКаЈБа∂∂аЈКа∂ѓ аЈАаЈТа∂Ї! рЯ§Р") return "<b>{}:</b>" \ "\n#MUTE" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(member.user.id, member.user.first_name)) else: message.reply_text("а∂ЄаЈЩа∂Є а∂іа∂їаЈТаЈБаЈУа∂ља∂Ъа∂ЇаЈП а∂ѓаЈРа∂±а∂Іа∂Єа∂≠аЈК а∂±аЈТаЈБаЈКаЈБа∂∂аЈКа∂ѓ а∂Ъа∂ї а∂За∂≠!) else: message.reply_text("а∂ЄаЈЩа∂Є а∂іа∂їаЈТаЈБаЈУа∂ља∂Ъа∂ЇаЈП аЈГа∂ВаЈАаЈПа∂ѓа∂ЇаЈЪ а∂±аЈЬа∂ЄаЈРа∂≠!") return ""
def start(bot: Bot, update: Update, args: List[str]): 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().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( photo=open("photo.PNG", "rb"), caption=PM_START_TEXT.format(escape_markdown(first_name), escape_markdown(bot.first_name), OWNER_ID), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( "+ Min tevlî komê xwe bike +", url='http://t.me/{}?startgroup=botstart'.format( bot.username)) ]])) else: update.effective_message.reply_text("Silav! Ez zindî me.")
def mute(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] user_id = extract_user(message, args) if not user_id: message.reply_text("Sessize almak için bana bir kullanıcı adı vermeniz veya susturulması gereken birine yanıt vermeniz gerekir.") return "" if user_id == bot.id: message.reply_text("susmayacağım!") return "" member = chat.get_member(int(user_id)) if member: if is_user_admin(chat, user_id, member=member): message.reply_text("Bir yöneticinin konuşmasını engelleyemiyorum diye korkuyorum!") elif member.can_send_messages is None or member.can_send_messages: bot.restrict_chat_member(chat.id, user_id, can_send_messages=False) message.reply_text("ağzına verdim konuşamaz") return "<b>{}:</b>" \ "\n#MUTE" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(member.user.id, member.user.first_name)) else: message.reply_text("Bu kullanıcı zaten sessiz!") else: message.reply_text("Bu kullanıcı sohbette yok!") return ""
def check_flood(bot: Bot, update: Update) -> str: user = update.effective_user # type: Optional[User] chat = update.effective_chat # type: Optional[Chat] msg = update.effective_message # type: Optional[Message] if not user: # ignore channels return "" # ignore admins if is_user_admin(chat, user.id): sql.update_flood(chat.id, None) return "" should_ban = sql.update_flood(chat.id, user.id) if not should_ban: return "" try: chat.kick_member(user.id) msg.reply_text( "Başqalarına ehtiyacınız yoxdur, artıq bu qrupa ehtiyacınız yoxdur..." ) return "<b>{}:</b>" \ "\n#BANNED" \ "\n<b>User:</b> {}" \ "\nFlooded the group.".format(html.escape(chat.title), mention_html(user.id, user.first_name)) except BadRequest: msg.reply_text( "Mənə İcazələr verməyincə bu xidmətdən istifadə edə bilməzsiniz.") sql.set_flood(chat.id, 0) return "<b>{}:</b>" \ "\n#Məlumat" \ "\nİcazələrinizi yoxlayın, buna görə də flood-a avtomatik olaraq aradan qaldırın.".format(chat.title)
def start(bot: Bot, update: Update, args: List[str]): chat = update.effective_chat # type: Optional[Chat] query = update.callback_query if update.effective_chat.type == "private": if len(args) >= 1: if args[0].lower() == "help": send_help(update.effective_chat.id, tld(chat.id, "send-help").format(""if not ALLOW_EXCL else tld(chat.id, "\nAll commands can either be used with `/` or `!`.\n"))) 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, user=False) else: send_settings(match.group(1), update.effective_user.id, user=True) elif args[0][1:].isdigit() and "rules" in IMPORTED: IMPORTED["rules"].send_rules(update, args[0], from_pm=True) else: send_start(bot, update) else: update.effective_message.reply_text("Yup! I'm Alive. PM Me To Know More About My Full Potential Use. And One Thing.. Please Don't Check Me Whether I'm Alive Or Not. Coz.. I'm Stable And Here To Manage Your Group At Any Cost. Thank You.")
def start(bot: Bot, update: Update, args: List[str]): 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() == "disasters": IMPORTED["disasters"].send_disasters(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( TECHNO_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="🔶PERTOLONGAN🔶", callback_data="help_back".format(bot.username)), InlineKeyboardButton(text="📌INSTAGRAM📌", url="https://www.instagram.com/imansiez77/")], [InlineKeyboardButton(text="ADD SAYA TO YOUR GROUP", url="t.me/{}?startgroup=true".format(bot.username)), InlineKeyboardButton(text="REPO PETERCORD USERBOT", url="https://github.com/ilham77mansiz/-PETERCORD-") ]])) else: update.effective_message.reply_text("Hi saya ONline")
def start(bot: Bot, update: Update, args: List[str]): 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() == "disasters": IMPORTED["disasters"].send_disasters(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( TECHNO_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="🤝HELP🤝", callback_data="help_back".format(bot.username)), InlineKeyboardButton(text="🧑💻My Owner🧑💻", url="t.me/d_rcybersec")], [InlineKeyboardButton(text="ADD MISS LIZA TO YOUR GROUP", url="t.me/{}?startgroup=true".format(bot.username)), InlineKeyboardButton(text="Support Group", url="https://t.me/joinchat/RJq_IX2cOCQY4Agz") ]])) else: update.effective_message.reply_text("Yess, im already online😍")
def start(bot: Bot, update: Update, args: List[str]): 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() == "disasters": IMPORTED["disasters"].send_disasters(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_text( 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 ME TO YOUR GROUP", url="t.me/{}?startgroup=true".format( bot.username)) ]])) else: update.effective_message.reply_text("Yo, whadup?🤧")
def mute(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] user_id = extract_user(message, args) if not user_id: message.reply_text("음소거를 할 사용자 id를 주거나, 또는 음소거할 사용자를 답장으로 알려주세요.") return "" if user_id == bot.id: message.reply_text("전 제 자신을 음소거할 수 없어요!") return "" member = chat.get_member(int(user_id)) if member: if is_user_admin(chat, user_id, member=member): message.reply_text("두렵게도 전 관리자가 말을 하는 것을 막을 수 없어요!") elif member.can_send_messages is None or member.can_send_messages: bot.restrict_chat_member(chat.id, user_id, can_send_messages=False) message.reply_text("음소거되었습니다!") return "<b>{}:</b>" \ "\n#음소거" \ "\n<b>관리자:</b> {}" \ "\n<b>사용자:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(member.user.id, member.user.first_name)) else: message.reply_text("해당 유저는 이미 음소거되어 있어요!") else: message.reply_text("해당 유저는 이 채팅방에 포함되어있지 않아요!") return ""
def check_user(user_id: int, bot: Bot, chat: Chat) -> Optional[str]: 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): reply = "I really wish I could mute admins...Perhaps a Punch?" return reply return None
def mute(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] user_id = extract_user(message, args) if not user_id: message.reply_text("ആരെയാണ് മ്യൂട്ട് ചെയ്യേണ്ടത് എന്നു പറഞ്ഞില്ല...") return "" if user_id == bot.id: message.reply_text("I'm not muting myself!") return "" member = chat.get_member(int(user_id)) if member: if is_user_admin(chat, user_id, member=member): message.reply_text("Afraid I can't stop an admin from talking!") elif member.can_send_messages is None or member.can_send_messages: bot.restrict_chat_member(chat.id, user_id, can_send_messages=False) message.reply_text("ലവന്റെ വായടച്ചിട്ടുണ്ട്!") return "<b>{}:</b>" \ "\n#MUTE" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(member.user.id, member.user.first_name)) else: message.reply_text("This user is already muted!") else: message.reply_text("This user isn't in the chat!") return ""
def start(bot: Bot, update: Update, args: List[str]): 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() == "disasters": IMPORTED["disasters"].send_disasters(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( TECHNO_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="🤝HELP🤝", callback_data="help_back".format(bot.username)), InlineKeyboardButton(text="🧑💻My Creator🧑💻", url="t.me/ALEXIIKUN")], [InlineKeyboardButton(text="ADD Luffymanagement bot TO YOUR GROUP", url="t.me/{}?startgroup=true".format(bot.username)), InlineKeyboardButton(text="Source Code", url="https://github.com/Alex/GRANDROBOT") ]])) else: update.effective_message.reply_text("Always online")
def start(bot: Bot, update: Update, args: List[str]): 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().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="Coisnto community", url="http://t.me/coinstocommunity") ]]) update.effective_message.reply_text( tld(update.effective_message, PM_START_TEXT).format(escape_markdown(first_name), escape_markdown(bot.first_name), OWNER_ID), disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN, reply_markup=buttons) else: update.effective_message.reply_text("Started, Successfully Lmao!")
def start(bot: Bot, update: Update, args: List[str]): 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().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( tg_bot_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="🔶 ʍყ รยקק๏гt ςђɑղղҽӀ 🔶", url="https://t.me/pf_hw".format( bot.username)) ]])) else: update.effective_message.reply_text(" i am not ded")
def check_update(self, update): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message 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): pass else: return None args = message.text.split()[1:] filter_result = self.filters(update) if filter_result: return args, filter_result else: return False return None
def check_flood(bot: Bot, update: Update) -> str: user = update.effective_user # type: Optional[User] chat = update.effective_chat # type: Optional[Chat] msg = update.effective_message # type: Optional[Message] if not user: # ignore channels return "" # ignore admins if is_user_admin(chat, user.id): sql.update_flood(chat.id, None) return "" should_ban = sql.update_flood(chat.id, user.id) if not should_ban: return "" try: chat.kick_member(user.id) msg.reply_text("Burada senin gibi çok konuşanları istemiyorum " "çık dışarı.") return "<b>{}:</b>" \ "\n#BANNED" \ "\n<b>User:</b> {}" \ "\nFlooded the group.".format(html.escape(chat.title), mention_html(user.id, user.first_name)) except BadRequest: msg.reply_text( "Kullanıcıları gruptan atma yetkisi verene kadar flood önleme sistemini devre dışı bırakacağım." ) sql.set_flood(chat.id, 0) return "<b>{}:</b>" \ "\n#INFO" \ "\nDon't have kick permissions, so automatically disabled antiflood.".format(chat.title)
def nomedia(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] conn = connected(bot, update, chat, user.id) if not conn == False: chatD = dispatcher.bot.getChat(conn) else: if chat.type == "private": exit(1) else: chatD = chat user_id = extract_user(message, args) if not user_id: message.reply_text( tld( chat.id, "You'll need to either give me a username to restrict, or reply to someone to be restricted." )) return "" if user_id == bot.id: message.reply_text(tld(chat.id, "I'm not restricting myself!")) return "" member = chatD.get_member(int(user_id)) if member: if is_user_admin(chatD, user_id, member=member): message.reply_text(tld(chat.id, "Afraid I can't restrict admins!")) elif member.can_send_messages is None or member.can_send_messages: bot.restrict_chat_member(chatD.id, user_id, can_send_messages=True, can_send_media_messages=False, can_send_other_messages=False, can_add_web_page_previews=False) keyboard = [] reply = tld(chat.id, "{} is restricted from sending media in {}!").format( mention_html(member.user.id, member.user.first_name), chatD.title) message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.HTML) return "#RESTRICTED" \ "\n<b>Chat:</b> {}"\ "\n<b>• Admin:</b> {}" \ "\n<b>• User:</b> {}" \ "\n<b>• ID:</b> <code>{}</code>".format(html.escape(chatD.title), mention_html(user.id, user.first_name), mention_html(member.user.id, member.user.first_name), user_id) else: message.reply_text( tld(chat.id, "This user is already restricted in {}!")) else: message.reply_text( tld(chat.id, "This user isn't in the {}!").format(chatD.title)) return ""
def temp_nomedia(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] conn = connected(bot, update, chat, user.id) if not conn == False: chatD = dispatcher.bot.getChat(conn) else: if chat.type == "private": exit(1) else: chatD = chat user_id, reason = extract_user_and_text(message, args) if not user_id: message.reply_text( tld(chat.id, "You don't seem to be referring to a user.")) return "" try: member = chat.get_member(user_id) except BadRequest as excp: if excp.message == "User not found": message.reply_text(tld(chat.id, "I can't seem to find this user")) return "" else: raise if is_user_admin(chat, user_id, member): message.reply_text( tld(chat.id, "I really wish I could restrict admins...")) return "" if user_id == bot.id: message.reply_text( tld(chat.id, "I'm not gonna RESTRICT myself, are you crazy?")) return "" if not reason: message.reply_text( tld(chat.id, "You haven't specified a time to restrict this user for!")) return "" split_reason = reason.split(None, 1) time_val = split_reason[0].lower() if len(split_reason) > 1: reason = split_reason[1] else: reason = "" mutetime = extract_time(message, time_val) if not mutetime: return "" log = "#TEMP RESTRICTED" \ "\n<b>Chat:</b> {}" \ "\n<b>• Admin:</b> {}" \ "\n<b>• User:</b> {}" \ "\n<b>• ID:</b> <code>{}</code>" \ "\n<b>• Time:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(member.user.id, member.user.first_name), user_id, time_val) if reason: log += "\n<b>• Reason:</b> {}".format(reason) try: if member.can_send_messages is None or member.can_send_messages: bot.restrict_chat_member(chat.id, user_id, until_date=mutetime, can_send_messages=True, can_send_media_messages=False, can_send_other_messages=False, can_add_web_page_previews=False) message.reply_text( tld(chat.id, "Restricted from sending media for {} in {}!").format( time_val, chatD.title)) return log else: message.reply_text( tld(chat.id, "This user is already restricted in {}.").format( chatD.title)) except BadRequest as excp: if excp.message == "Reply message not found": # Do not reply message.reply_text(tld(chat.id, "Restricted for {} in {}!").format( time_val, chatD.title), quote=False) return log else: LOGGER.warning(update) LOGGER.exception("ERROR muting user %s in chat %s (%s) due to %s", user_id, chat.title, chat.id, excp.message) message.reply_text( tld(chat.id, "Well damn, I can't restrict that user.")) return ""
def start(update: Update, context: CallbackContext): '''#TODO Params: update: Update - context: CallbackContext - ''' chat = update.effective_chat args = context.args if update.effective_chat.type == "private": if len(args) >= 1: if args[0].lower() == "help": send_help(update.effective_chat.id, (gs(chat.id, "pm_help_text"))) 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( photo=KIGYO_IMG, caption=gs(chat.id, "pm_start_text").format( escape_markdown(first_name), escape_markdown(context.bot.first_name), OWNER_ID, ), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup([ [ InlineKeyboardButton( text=gs(chat.id, "add_bot_to_group_btn"), url="t.me/{}?startgroup=true".format( context.bot.username), ), InlineKeyboardButton( text="Help", url="t.me/{}?start=help".format( context.bot.username), ), ], [ InlineKeyboardButton( text=gs(chat.id, "MY HERO_link_btn"), url=f"https://t.me/@ABHI_VILAN", ), InlineKeyboardButton( text=gs(chat.id, "My Creatir_link_btn"), url="https://t.me/@ABHI_VILAN", ), ], [ InlineKeyboardButton( text=gs(chat.id, "src_btn"), url="https://github.com/Dank-del/EnterpriseALRobot", ), InlineKeyboardButton( text="Try inline mode", switch_inline_query_current_chat="", ) ], ]), ) else: update.effective_message.reply_text(gs(chat.id, "grp_start_text"))
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, can't even be warned!") 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: # kick chat.unban_member(user.id) reply = "{} warnings, {} has been kicked!".format( limit, mention_html(user.id, user.first_name)) else: # ban chat.kick_member(user.id) reply = "{} warnings, {} has been banned!".format( limit, mention_html(user.id, user.first_name)) for warn_reason in reasons: reply += "\n - {}".format(html.escape(warn_reason)) message.bot.send_sticker(chat.id, BAN_STICKER) # banhammer marie sticker keyboard = [] log_reason = "<b>{}:</b>" \ "\n#WARN_BAN" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {} (<code>{}</code>)" \ "\n<b>Reason:</b> {}"\ "\n<b>Counts:</b> <code>{}/{}</code>".format(html.escape(chat.title), warner_tag, mention_html(user.id, user.first_name), user.id, reason, num_warns, limit) else: keyboard = InlineKeyboardMarkup([[ InlineKeyboardButton("Remove warn", callback_data="rm_warn({})".format(user.id)) ]]) reply = "{} has {}/{} warnings... watch out!".format( mention_html(user.id, user.first_name), num_warns, limit) if reason: reply += "\nReason for last warn:\n{}".format(html.escape(reason)) log_reason = "<b>{}:</b>" \ "\n#WARN" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {} (<code>{}</code>)" \ "\n<b>Reason:</b> {}"\ "\n<b>Counts:</b> <code>{}/{}</code>".format(html.escape(chat.title), warner_tag, mention_html(user.id, user.first_name), user.id, reason, num_warns, limit) 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
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 TIGER_USERS: if warner: message.reply_text("Tigers cant be warned.") else: message.reply_text("Tiger triggered an auto warn filter!\n I can't warn tigers but they should avoid abusing this.") return if user.id in WHITELIST_USERS: if warner: message.reply_text("Wolf disasters are warn immune.") else: message.reply_text("Wolf Disaster triggered an auto warn filter!\n I can't warn wolves 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) # Saitama'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
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))
def temp_mute(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] user_id, reason = extract_user_and_text(message, args) if not user_id: message.reply_text("You don't seem to be referring to a user.") return "" try: member = chat.get_member(user_id) except BadRequest as excp: if excp.message == "User not found": message.reply_text("I can't seem to find this user") return "" else: raise if is_user_admin(chat, user_id, member): message.reply_text("I really wish I could mute admins...") return "" if user_id == bot.id: message.reply_text("I'm not gonna MUTE myself, are you crazy?") return "" if not reason: message.reply_text( "You haven't specified a time to mute this user for!") return "" split_reason = reason.split(None, 1) time_val = split_reason[0].lower() if len(split_reason) > 1: reason = split_reason[1] else: reason = "" mutetime = extract_time(message, time_val) if not mutetime: return "" log = "<b>{}:</b>" \ "\n#TEMP MUTED" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {}" \ "\n<b>Time:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(member.user.id, member.user.first_name), time_val) if reason: log += "\n<b>Reason:</b> {}".format(reason) try: if member.can_send_messages is None or member.can_send_messages: bot.restrict_chat_member(chat.id, user_id, until_date=mutetime, can_send_messages=False) message.reply_text("shut up! 😠 Muted for {}!".format(time_val)) return log else: message.reply_text("This user is already muted.") except BadRequest as excp: if excp.message == "Reply message not found": # Do not reply message.reply_text("shut up! 😠 Muted for {}!".format(time_val), quote=False) return log else: LOGGER.warning(update) 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 ""