def check_update(self, update): if isinstance(update, Update) and update.effective_message: message = update.effective_message if message.text and len(message.text) > 1 and any(message.text.startswith(start) for start in CMD_STARTERS): command = message.text[1:message.entities[0].length] args = message.text.split()[1:] command = command.split('@') command.append(message.bot.username) if not (command[0].lower() in self.command and 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 and sql.is_disable_del(chat.id): # disabled and should delete update.effective_message.delete() if not is_disabled: return None else: return args, filter_result return args, filter_result else: return False
def check_update(self, update): if isinstance(update, Update) and update.effective_message: message = update.effective_message if (message.entities and message.entities[0].type == MessageEntity.BOT_COMMAND and message.entities[0].offset == 0): command = message.text[1:message.entities[0].length] args = message.text.split()[1:] command = command.split('@') command.append(message.bot.username) if not (command[0].lower() in self.command and command[1].lower() == message.bot.username.lower()): return None filter_result = self.filters(update) if filter_result: chat = update.effective_chat # 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 and sql.is_disable_del(chat.id): # disabled and should delete update.effective_message.delete() if not is_disabled: return None else: return args, filter_result return args, filter_result else: return False
def get_settings(bot: Bot, update: Update): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] msg = update.effective_message # type: Optional[Message] args = msg.text.split(None, 1) spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id) if spam == True: return update.effective_message.reply_text( "Saya kecewa dengan anda, saya tidak akan mendengar kata-kata anda sekarang!" ) # ONLY send settings in PM if chat.type != chat.PRIVATE: if is_user_admin(chat, user.id): text = "Klik di sini untuk mendapatkan pengaturan obrolan ini, serta milik Anda." msg.reply_text(text, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( text="Pengaturan", url="t.me/{}?start=stngs_{}".format( bot.username, chat.id)) ]])) else: text = "Klik di sini untuk memeriksa pengaturan Anda." else: send_settings(chat.id, user.id, True)
def get_settings(update, context): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] msg = update.effective_message # type: Optional[Message] args = msg.text.split(None, 1) # ONLY send settings in PM if chat.type != chat.PRIVATE: if is_user_admin(chat, user.id): text = tl( update.effective_message, "Klik di sini untuk mendapatkan pengaturan obrolan ini, serta milik Anda." ) msg.reply_text(text, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( text="Pengaturan", url="t.me/{}?start=stngs_{}".format( context.bot.username, chat.id)) ]])) # else: # text = tl(update.effective_message, "Klik di sini untuk memeriksa pengaturan Anda.") else: send_settings(chat.id, user.id, True)
def mute(bot: Bot, update: Update, args: List[str]) -> str: spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id) if spam == True: return update.effective_message.reply_text("Saya kecewa dengan anda, saya tidak akan mendengar kata-kata anda sekarang!") 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("Anda harus memberi saya nama pengguna untuk membungkam, atau membalas seseorang untuk dibisukan.") return "" conn = connected(bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = dispatcher.bot.getChat(conn).title text = "Dia telah dibisukan pada *{}*! 😆".format(chat_name) else: if update.effective_message.chat.type == "private": update.effective_message.reply_text("Anda bisa lakukan command ini pada grup, bukan pada PM") return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title text = "Dia telah dibisukan! 😆" if user_id == bot.id: message.reply_text("Saya tidak akan membungkam diri saya sendiri!") return "" check = bot.getChatMember(chat.id, user.id) if check['can_restrict_members'] == False: message.reply_text("Anda tidak punya hak untuk membatasi seseorang.") return "" member = chat.get_member(int(user_id)) if member: if is_user_admin(chat, user_id, member=member): message.reply_text("Saya tidak bisa menghentikan seorang admin berbicara!") 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(text, parse_mode="markdown") return "<b>{}:</b>" \ "\n#MUTE" \ "\n<b>Admin:</b> {}" \ "\n<b>Pengguna:</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("Pengguna ini sudah dibungkam!") else: message.reply_text("Pengguna ini tidak ada dalam obrolan!") return ""
def start(update, context): if update.effective_chat.type == "private": args = context.args if len(args) >= 1: if args[0].lower() == "help": send_help(update.effective_chat.id, tl(update.effective_message, HELP_STRINGS)) elif args[0].lower() == "get_notes": update.effective_message.reply_text(tl(update.effective_message, "Now you can get notes in group.")) 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) elif args[0][:4] == "wiki": wiki = args[0].split("-")[1].replace('_', ' ') message = update.effective_message getlang = langsql.get_lang(message) if getlang == "id": wikipedia.set_lang("id") pagewiki = wikipedia.page(wiki) judul = pagewiki.title summary = pagewiki.summary if len(summary) >= 4096: summary = summary[:4000]+"..." message.reply_text("<b>{}</b>\n{}".format(judul, summary), parse_mode=ParseMode.HTML, reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton(text=tl(update.effective_message, "Read on Wikipedia"), url=pagewiki.url)]])) elif args[0][:6].lower() == "verify": chat_id = args[0].split("_")[1] verify_welcome(update, context, chat_id) elif args[0][:6].lower() == "verify": chat_id = args[0].split("_")[1] verify_welcome(update, context, chat_id) else: first_name = update.effective_user.first_name buttons = InlineKeyboardMarkup( [[InlineKeyboardButton(text="👤Add me to your group", url="https://t.me/ManagerGithubRobot?startgroup=new")], [InlineKeyboardButton(text="⚙️ Connections", callback_data="main_connect")], [InlineKeyboardButton(text="🐳 Language", callback_data="main_setlang"), InlineKeyboardButton(text="❓ Help", url="https://t.me/ManagerGithubRobot?start=help")]]) update.effective_message.reply_text( tl(update.effective_message, PM_START_TEXT).format(escape_markdown(first_name), escape_markdown(context.bot.first_name), OWNER_ID), disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN, reply_markup=buttons) else: update.effective_message.reply_text(tl(update.effective_message, "Ada yang bisa saya bantu? 😊"))
def mute(update, context): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] args = context.args user_id = extract_user(message, args) if not user_id or user_id == "error": send_message(update.effective_message, tl(update.effective_message, "Anda harus memberi saya nama pengguna untuk membungkam, atau membalas seseorang untuk dibisukan.")) return "" conn = connected(context.bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = dispatcher.bot.getChat(conn).title text = tl(update.effective_message, "Terbisukan pada *{}*! 😆").format(chat_name) else: if update.effective_message.chat.type == "private": update.effective_send_message(update.effective_message, tl(update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM")) return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title text = tl(update.effective_message, "Terbisukan! 😆") if user_id == context.bot.id: send_message(update.effective_message, tl(update.effective_message, "Saya tidak akan membungkam diri saya sendiri!")) return "" check = context.bot.getChatMember(chat.id, user.id) if check['can_restrict_members'] == False: send_message(update.effective_message, tl(update.effective_message, "Anda tidak punya hak untuk membatasi seseorang.")) return "" member = chat.get_member(int(user_id)) if member: if is_user_admin(chat, user_id, member=member): send_message(update.effective_message, tl(update.effective_message, "Saya tidak bisa menghentikan seorang admin berbicara!")) elif member.can_send_messages is None or member.can_send_messages: context.bot.restrict_chat_member(chat.id, user_id, permissions=ChatPermissions(can_send_messages=False)) send_message(update.effective_message, text, parse_mode="markdown") 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: send_message(update.effective_message, tl(update.effective_message, "Pengguna ini sudah dibungkam!")) else: send_message(update.effective_message, tl(update.effective_message, "Pengguna ini tidak ada dalam obrolan!")) return ""
def check_flood(update, context) -> 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: getmode, getvalue = sql.get_flood_setting(chat.id) if getmode == 1: chat.kick_member(user.id) execstrings = tl(update.effective_message, "Keluar!") tag = "BANNED" elif getmode == 2: chat.kick_member(user.id) chat.unban_member(user.id) execstrings = tl(update.effective_message, "Keluar!") tag = "KICKED" elif getmode == 3: context.bot.restrict_chat_member(chat.id, user.id, permissions=ChatPermissions(can_send_messages=False)) execstrings = tl(update.effective_message, "Sekarang kamu diam!") tag = "MUTED" elif getmode == 4: bantime = extract_time(msg, getvalue) chat.kick_member(user.id, until_date=bantime) execstrings = tl(update.effective_message, "Keluar selama {}!").format(getvalue) tag = "TBAN" elif getmode == 5: mutetime = extract_time(msg, getvalue) context.bot.restrict_chat_member(chat.id, user.id, until_date=mutetime, permissions=ChatPermissions(can_send_messages=False)) execstrings = tl(update.effective_message, "Sekarang kamu diam selama {}!").format(getvalue) tag = "TMUTE" send_message(update.effective_message, tl(update.effective_message, "Saya tidak suka orang yang mengirim pesan beruntun. Tapi kamu hanya membuat " "saya kecewa. {}").format(execstrings)) return "<b>{}:</b>" \ "\n#{}" \ "\n<b>User:</b> {}" \ "\nFlooded the group.".format(tag, html.escape(chat.title), mention_html(user.id, user.first_name)) except BadRequest: send_message(update.effective_message, tl(update.effective_message, "Saya tidak bisa menendang orang di sini, beri saya izin terlebih dahulu! Sampai saat itu, saya akan menonaktifkan antiflood.")) sql.set_flood(chat.id, 0) return "<b>{}:</b>" \ "\n#INFO" \ "\n{}".format(chat.title, tl(update.effective_message, "Tidak memiliki izin kick, jadi secara otomatis menonaktifkan antiflood."))
def start(update, context): if update.effective_chat.type == "private": args = context.args if len(args) >= 1: if args[0].lower() == "help": send_help(update.effective_chat.id, tl(update.effective_message, HELP_STRINGS)) elif args[0].lower() == "get_notes": update.effective_message.reply_text(tl(update.effective_message, "Anda sekarang dapat mengambil catatan di grup.")) 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) elif args[0][:4] == "wiki": wiki = args[0].split("-")[1].replace('_', ' ') message = update.effective_message getlang = langsql.get_lang(message) if getlang == "id": wikipedia.set_lang("id") pagewiki = wikipedia.page(wiki) judul = pagewiki.title summary = pagewiki.summary if len(summary) >= 4096: summary = summary[:4000]+"..." message.reply_text("<b>{}</b>\n{}".format(judul, summary), parse_mode=ParseMode.HTML, reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton(text=tl(update.effective_message, "Baca di Wikipedia"), url=pagewiki.url)]])) elif args[0][:6].lower() == "verify": chat_id = args[0].split("_")[1] verify_welcome(update, context, chat_id) else: first_name = update.effective_user.first_name buttons = InlineKeyboardMarkup( [ [InlineKeyboardButton(text="🤿 Language", callback_data="main_setlang"), InlineKeyboardButton(text="📡 Connect Group", callback_data="main_connect")], [InlineKeyboardButton(text="🦾 Support Group", url="https://t.me/gangofmafiateam"), InlineKeyboardButton(text="📞 Contact Devoloper", url="https://t.me/prabhasha999")], [InlineKeyboardButton(text="⛑ Help", url="https://t.me/{}?start=help".format(context.bot.username)), InlineKeyboardButton(text="🤖 About Developer", url="https://sltechcom.webnode.com/about-us/")], [InlineKeyboardButton(text="👒 Add me to your group", url="https://t.me/{}?startgroup=new".format(context.bot.username))]]) update.effective_message.reply_photo(DAISY_IMG, tl(update.effective_message, PM_START_TEXT).format(escape_markdown(first_name), escape_markdown(context.bot.first_name), OWNER_ID), disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN, reply_markup=buttons) else: update.effective_message.reply_text(tl(update.effective_message, "Ada yang bisa saya bantu? 😊"))
def start(update, context): if update.effective_chat.type == "private": args = context.args if len(args) >= 1: if args[0].lower() == "help": send_help(update.effective_chat.id, tl(update.effective_message, HELP_STRINGS)) elif args[0].lower() == "get_notes": update.effective_message.reply_text(tl(update.effective_message, "Anda sekarang dapat mengambil catatan di grup.")) 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) elif args[0][:4] == "wiki": wiki = args[0].split("-")[1].replace('_', ' ') message = update.effective_message getlang = langsql.get_lang(message) if getlang == "id": wikipedia.set_lang("id") pagewiki = wikipedia.page(wiki) judul = pagewiki.title summary = pagewiki.summary if len(summary) >= 4096: summary = summary[:4000]+"..." message.reply_text("<b>{}</b>\n{}".format(judul, summary), parse_mode=ParseMode.HTML, reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton(text=tl(update.effective_message, "Baca di Wikipedia"), url=pagewiki.url)]])) elif args[0][:6].lower() == "verify": chat_id = args[0].split("_")[1] verify_welcome(update, context, chat_id) else: first_name = update.effective_user.first_name buttons = InlineKeyboardMarkup( [ [InlineKeyboardButton(text="💭Language💭 ", callback_data="main_setlang"), InlineKeyboardButton(text="⚙️Connect Group⚙️", callback_data="main_connect")], [InlineKeyboardButton(text="🚂join Hogwarts🏰", url="https://t.me/TheRex2k20"), InlineKeyboardButton(text="🏰🚂Hogwarts Channel🚂🏰", url="https://t.me/HogwartsPlus")], [InlineKeyboardButton(text="🌐Help🌐", url="https://t.me/{}?start=help".format(context.bot.username)), InlineKeyboardButton(text="💖About Developer💝", url="https://t.me/percy_jackson_4")], [InlineKeyboardButton(text="❤💚Sorting Hat💙💛", url="https://www.wizardingworld.com")]]) update.effective_message.reply_photo(DAISY_IMG, tl(update.effective_message, PM_START_TEXT).format(escape_markdown(first_name), escape_markdown(context.bot.first_name), OWNER_ID), disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN, reply_markup=buttons) else: update.effective_message.reply_text(tl(update.effective_message, "Ada yang bisa saya bantu? 😊"))
def start(bot: Bot, update: Update, args: List[str]): spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id) if spam == True: return update.effective_message.reply_text( "Saya kecewa dengan anda, saya tidak akan mendengar kata-kata anda sekarang!" ) 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) elif args[0][:4] == "wiki": wiki = args[0].split("-")[1].replace('_', ' ') message = update.effective_message wikipedia.set_lang("id") try: pagewiki = wikipedia.page(wiki) except wikipedia.exceptions.PageError: wikipedia.set_lang("en") pagewiki = wikipedia.page(wiki) judul = pagewiki.title summary = pagewiki.summary if len(summary) >= 4096: summary = summary[:4000] + "..." message.reply_text("<b>{}</b>\n{}".format(judul, summary), parse_mode=ParseMode.HTML, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( text="Baca di Wikipedia", url=pagewiki.url) ]])) 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) else: update.effective_message.reply_text("Ada yang bisa saya bantu? 😊")
def enforce_gban(update, context): # 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(context.bot.id).can_restrict_members: user = update.effective_user # type: Optional[User] chat = update.effective_chat # type: Optional[Chat] msg = update.effective_message # type: Optional[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 # type: Optional[User] if user and not is_user_admin(chat, user.id): check_and_ban(update, user.id, should_message=False)
def start(bot: Bot, update: Update, args: List[str]): spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id, update.effective_message) if spam == True: return if update.effective_chat.type == "private": if len(args) >= 1: if args[0].lower() == "help": send_help(update.effective_chat.id, tl(update.effective_message, HELP_STRINGS)) elif args[0].lower() == "get_notes": update.effective_message.reply_text(tl(update.effective_message, "Anda sekarang dapat mengambil catatan di grup.")) 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) elif args[0][:4] == "wiki": wiki = args[0].split("-")[1].replace('_', ' ') message = update.effective_message getlang = langsql.get_lang(message) if getlang == "id": wikipedia.set_lang("id") pagewiki = wikipedia.page(wiki) judul = pagewiki.title summary = pagewiki.summary if len(summary) >= 4096: summary = summary[:4000]+"..." message.reply_text("<b>{}</b>\n{}".format(judul, summary), parse_mode=ParseMode.HTML, reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton(text=tl(update.effective_message, "Baca di Wikipedia"), url=pagewiki.url)]])) else: first_name = update.effective_user.first_name buttons = InlineKeyboardMarkup( [[InlineKeyboardButton(text="🎉 Tambahkan ke Grup", url="https://t.me/Balqissbot?startgroup=new")], [InlineKeyboardButton(text="💭 Bahasa", callback_data="main_setlang"), InlineKeyboardButton(text="⚙️ Hubungkan Grup", callback_data="main_connect")], [InlineKeyboardButton(text="👥 Grup Pendukung", url="https://t.me/Balqisdiskussi"), InlineKeyboardButton(text="🔔 Update Channel", url="https://t.me/balqisupdate")], [InlineKeyboardButton(text="❓ Bantuan", url="https://t.me/Balqissbot?start=help"), InlineKeyboardButton(text="🤑 Donasi", url="https://t.me/SquidwardTentacles0")]]) update.effective_message.reply_text( tl(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(tl(update.effective_message, "Ada yang bisa Balqis bantu sayang😘 ?"))
def start(bot: Bot, update: Update, args: List[str]): spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id, update.effective_message) if spam == True: return if update.effective_chat.type == "private": if len(args) >= 1: if args[0].lower() == "help": send_help(update.effective_chat.id, tl(update.effective_message, HELP_STRINGS)) elif args[0].lower() == "get_notes": update.effective_message.reply_text(tl(update.effective_message, "Anda sekarang dapat mengambil catatan di grup.")) 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) elif args[0][:4] == "wiki": wiki = args[0].split("-")[1].replace('_', ' ') message = update.effective_message getlang = langsql.get_lang(message) if getlang == "id": wikipedia.set_lang("id") pagewiki = wikipedia.page(wiki) judul = pagewiki.title summary = pagewiki.summary if len(summary) >= 4096: summary = summary[:4000]+"..." message.reply_text("<b>{}</b>\n{}".format(judul, summary), parse_mode=ParseMode.HTML, reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton(text=tl(update.effective_message, "Baca di Wikipedia"), url=pagewiki.url)]])) else: first_name = update.effective_user.first_name buttons = InlineKeyboardMarkup( [[InlineKeyboardButton(text="🎉 Add me to your group", url="https://t.me/NLydW_Bot?startgroup=new")], [InlineKeyboardButton(text="💭 Language", callback_data="main_setlang"), InlineKeyboardButton(text="⚙️ Connect Group", callback_data="main_connect")], [InlineKeyboardButton(text="👥 Support Group", url="https://t.me/joinchat/RNFD7UXOd8uG0B_0MCEzeA"), InlineKeyboardButton(text="🔔 Update Channel", url="https://t.me/GROUPSKEMER")], [InlineKeyboardButton(text="❓ Help", url="https://t.me/NLydW_Bot?start=help"), InlineKeyboardButton(text="💖 Donate", url="http://paypal.me/AIrvandi")]]) update.effective_message.reply_text( tl(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(tl(update.effective_message, "Ada yang bisa saya bantu? 😊"))
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(tl(update.effective_message, "Saya berharap saya bisa... tetapi Anda seorang admin 😒")) return spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id, update.effective_message) if spam == True: return res = update.effective_chat.unban_member(user_id) # unban on current user = kick if res: update.effective_message.reply_text(tl(update.effective_message, "Tidak masalah 😊")) else: update.effective_message.reply_text(tl(update.effective_message, "Hah? Aku tidak bisa 🙄"))
def check_update(self, update): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[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.lower()): return command in ADMIN_CMDS and is_user_admin(chat, user.id) # not disabled else: return True return False
def kickme(update, context): user_id = update.effective_message.from_user.id if is_user_admin(update.effective_chat, user_id): send_message( update.effective_message, tl(update.effective_message, "Saya berharap saya bisa... tetapi Anda seorang admin 😒")) return res = update.effective_chat.unban_member( user_id) # unban on current user = kick if res: send_message(update.effective_message, tl(update.effective_message, "Tidak masalah 😊")) else: send_message(update.effective_message, tl(update.effective_message, "Hah? Aku tidak bisa 🙄"))
def get_settings(update, context): chat = update.effective_chat user = update.effective_user msg = update.effective_message args = msg.text.split(None, 1) if chat.type != chat.PRIVATE: if is_user_admin(chat, user.id): text = tl( update.effective_message, "Clique aqui para obter essas configurações do chat, assim como as suas." ) msg.reply_text(text, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( text="Configurações", url="t.me/{}?start=stngs_{}".format( context.bot.username, chat.id)) ]])) else: send_settings(chat.id, user.id, True)
def warn(user: User, chat: Chat, reason: str, message: Message, warner: User = None, conn=False) -> str: if is_user_admin(chat, user.id): message.reply_text("Sayangnya admin tidak bisa di warn 😔") return "" if warner: warner_tag = mention_html(warner.id, warner.first_name) else: warner_tag = "Filter peringatan otomatis." 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 = "{} peringatan, {} telah ditendang!".format( limit, mention_html(user.id, user.first_name)) else: # ban chat.kick_member(user.id) reply = "{} peringatan, {} telah diblokir!".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>Pengguna:</b> {} (<code>{}</code>)" \ "\n<b>Alasan:</b> {}"\ "\n<b>Jumlah:</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("Hapus peringatan", callback_data="rm_warn({})".format(user.id)) ]]) reply = "{} punya {}/{} peringatan... Hati-hati!".format( mention_html(user.id, user.first_name), num_warns, limit) if reason: reply += "\nAlasan pada peringatan terakhir:\n{}".format( html.escape(reason)) log_reason = "<b>{}:</b>" \ "\n#WARN" \ "\n<b>Admin:</b> {}" \ "\n<b>Pengguna:</b> {} (<code>{}</code>)" \ "\n<b>Alasan:</b> {}"\ "\n<b>Jumlah:</b> <code>{}/{}</code>".format(html.escape(chat.title), warner_tag, mention_html(user.id, user.first_name), user.id, reason, num_warns, limit) try: if conn: message.bot.sendMessage(chat.id, reply, reply_markup=keyboard, parse_mode=ParseMode.HTML) else: message.bot.sendMessage(chat.id, reply, reply_to_message_id=message.message_id, reply_markup=keyboard, parse_mode=ParseMode.HTML) #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 if conn: message.bot.sendMessage(chat.id, reply, reply_markup=keyboard, parse_mode=ParseMode.HTML) else: message.bot.sendMessage(chat.id, reply, reply_to_message_id=message.message_id, reply_markup=keyboard, parse_mode=ParseMode.HTML, quote=False) #message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.HTML, quote=False) else: raise return log_reason
def unlock(update, context) -> str: args = context.args chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] if is_user_admin(chat, message.from_user.id): if len(args) >= 1: ltype = args[0].lower() if ltype in LOCK_TYPES: # Connection check conn = connected(context.bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = chat.title text = tl( update.effective_message, "Tidak terkunci *{}* untuk semua orang pada *{}*!" ).format(ltype, chat_name) else: if update.effective_message.chat.type == "private": send_message( update.effective_message, tl( update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM" )) return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title text = tl( update.effective_message, "Tidak terkunci *{}* untuk semua orang!").format(ltype) sql.update_lock(chat.id, ltype, locked=False) send_message(update.effective_message, text, parse_mode="markdown") return "<b>{}:</b>" \ "\n#UNLOCK" \ "\n<b>Admin:</b> {}" \ "\nUnlocked <code>{}</code>.".format(html.escape(chat.title), mention_html(user.id, user.first_name), ltype) elif ltype in UNLOCK_CHAT_RESTRICTION: # Connection check conn = connected(context.bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = chat.title text = tl( update.effective_message, "Izin tidak terkunci *{}* untuk semua orang pada *{}*!" ).format(ltype, chat_name) else: if update.effective_message.chat.type == "private": send_message( update.effective_message, tl( update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM" )) return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title text = tl( update.effective_message, "Izin tidak terkunci *{}* untuk semua orang!").format( ltype) current_permission = context.bot.getChat(chat_id).permissions context.bot.set_chat_permissions( chat_id=chat_id, permissions=get_permission_list( eval(str(current_permission)), UNLOCK_CHAT_RESTRICTION[ltype.lower()])) send_message(update.effective_message, text, parse_mode="markdown") return "<b>{}:</b>" \ "\n#UNLOCK" \ "\n<b>Admin:</b> {}" \ "\nUnlocked <code>{}</code>.".format(html.escape(chat.title), mention_html(user.id, user.first_name), ltype) else: send_message( update.effective_message, tl( update.effective_message, "Apa yang Anda coba untuk membuka kunci...? Coba /locktypes untuk daftar kunci yang dapat dikunci" )) else: send_message( update.effective_message, tl(update.effective_message, "Apa yang Anda coba untuk buka kunci...?")) return ""
def temp_mute(bot: Bot, update: Update, args: List[str]) -> str: spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id, update.effective_message) if spam == True: return 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: send_message( update.effective_message, tl(update.effective_message, "Anda sepertinya tidak mengacu pada pengguna.")) return "" conn = connected(bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: if update.effective_message.chat.type == "private": update.effective_send_message( update.effective_message, tl(update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM")) return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title try: member = chat.get_member(user_id) except BadRequest as excp: if excp.message == "User not found": send_message( update.effective_message, tl(update.effective_message, "Saya tidak dapat menemukan pengguna ini")) return "" else: raise if is_user_admin(chat, user_id, member): send_message( update.effective_message, tl(update.effective_message, "Saya benar-benar berharap dapat membisukan admin...")) return "" if user_id == bot.id: send_message( update.effective_message, tl( update.effective_message, "Saya tidak akan membisukan diri saya sendiri, apakah kamu gila?" )) return "" check = bot.getChatMember(chat.id, user.id) if check['can_restrict_members'] == False: send_message( update.effective_message, tl(update.effective_message, "Anda tidak punya hak untuk membatasi seseorang.")) return "" if not reason: send_message( update.effective_message, tl( update.effective_message, "Anda belum menetapkan waktu untuk menonaktifkan pengguna ini!" )) 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#TMUTE" \ "\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) if conn: text = tl(update.effective_message, "Dibisukan untuk *{}* pada *{}*!").format( time_val, chat_name) else: text = tl(update.effective_message, "Dibisukan untuk *{}*!").format(time_val) send_message(update.effective_message, text, parse_mode="markdown") return log else: send_message( update.effective_message, tl(update.effective_message, "Pengguna ini sudah dibungkam.")) except BadRequest as excp: if excp.message == "Reply message not found": # Do not reply send_message(update.effective_message, tl(update.effective_message, "Dibisukan untuk *{}*!").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) send_message( update.effective_message, tl(update.effective_message, "Yah sial, aku tidak bisa membisukan pengguna itu.")) return ""
def unmute(bot: Bot, update: Update, args: List[str]) -> str: spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id, update.effective_message) if spam == True: return 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: send_message( update.effective_message, tl( update.effective_message, "Anda harus memberi saya nama pengguna untuk menyuarakan, atau membalas seseorang untuk disuarakan." )) return "" conn = connected(bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = dispatcher.bot.getChat(conn).title text = tl(update.effective_message, "Pengguna ini sudah bisa untuk berbicara pada *{}*.").format( chat_name) text2 = tl(update.effective_message, "Dia telah disuarakan pada *{}*.").format(chat_name) else: if update.effective_message.chat.type == "private": update.effective_send_message( update.effective_message, tl(update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM")) return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title text = tl(update.effective_message, "Pengguna ini sudah bisa untuk berbicara.") text2 = "Dia telah disuarakan." check = bot.getChatMember(chat.id, user.id) if check['can_restrict_members'] == False: send_message( update.effective_message, tl(update.effective_message, "Anda tidak punya hak untuk membatasi seseorang.")) return "" member = chat.get_member(int(user_id)) if member: if is_user_admin(chat, user_id, member=member): send_message( update.effective_message, tl(update.effective_message, "Dia adalah admin, apa yang Anda harapkan kepada saya?")) return "" elif member.status != 'kicked' and member.status != 'left': if member.can_send_messages and member.can_send_media_messages \ and member.can_send_other_messages and member.can_add_web_page_previews: send_message(update.effective_message, text, parse_mode="markdown") return "" else: bot.restrict_chat_member(chat.id, int(user_id), can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True) send_message(update.effective_message, text2, parse_mode="markdown") return "<b>{}:</b>" \ "\n#UNMUTE" \ "\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: send_message( update.effective_message, tl( update.effective_message, "Pengguna ini bahkan tidak dalam obrolan, menyuarakannya tidak akan membuat mereka berbicara lebih dari " "yang sudah mereka lakukan!")) return ""
def start(update, context): if update.effective_chat.type == "private": args = context.args if len(args) >= 1: if args[0].lower() == "help": send_help(update.effective_chat.id, tl(update.effective_message, HELP_STRINGS)) elif args[0].lower() == "get_notes": update.effective_message.reply_text( tl(update.effective_message, "Anda sekarang dapat mengambil catatan di grup.")) 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) elif args[0][:4] == "wiki": wiki = args[0].split("-")[1].replace('_', ' ') message = update.effective_message getlang = langsql.get_lang(message) if getlang == "id": wikipedia.set_lang("id") pagewiki = wikipedia.page(wiki) judul = pagewiki.title summary = pagewiki.summary if len(summary) >= 4096: summary = summary[:4000] + "..." message.reply_text("<b>{}</b>\n{}".format(judul, summary), parse_mode=ParseMode.HTML, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton(text=tl( update.effective_message, "Baca di Wikipedia"), url=pagewiki.url) ]])) elif args[0][:6].lower() == "verify": chat_id = args[0].split("_")[1] verify_welcome(update, context, chat_id) else: first_name = update.effective_user.first_name buttons = InlineKeyboardMarkup( [[ InlineKeyboardButton( text="👑 Add me to your group", url="https://t.me/{}?startgroup=new".format( context.bot.username)) ], [ InlineKeyboardButton(text="💭 Language", callback_data="main_setlang"), InlineKeyboardButton(text="⚙️ Connect Group", callback_data="main_connect") ], [ InlineKeyboardButton(text="👥 Support Group", url="http://t.me/notimetosleep1"), InlineKeyboardButton(text="🌐 Support Channel", url="https://t.me/nttschennel") ], [ InlineKeyboardButton( text="❓ Help", url="https://t.me/{}?start=help".format( context.bot.username)), InlineKeyboardButton( text="👻 Profil CESPER", url="https://id.m.wikipedia.org/wiki/Casper_(film)") ]]) update.effective_message.reply_photo( "https://i.ibb.co/F3MnkFd/IMG-20210123-174846-513.jpg", tl(update.effective_message, PM_START_TEXT).format( escape_markdown(first_name), escape_markdown(context.bot.first_name), OWNER_ID), disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN, reply_markup=buttons) else: update.effective_message.reply_text( tl(update.effective_message, "ADA YANG BISA SAYA KENTOD? 💦"))
def start(bot: Bot, update: Update, args: List[str]): spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id, update.effective_message) if spam == True: return if update.effective_chat.type == "private": if len(args) >= 1: if args[0].lower() == "help": send_help(update.effective_chat.id, tl(update.effective_message, HELP_STRINGS)) elif args[0].lower() == "get_notes": update.effective_message.reply_text( tl(update.effective_message, "Anda sekarang dapat mengambil catatan di grup.")) 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) elif args[0][:4] == "wiki": wiki = args[0].split("-")[1].replace('_', ' ') message = update.effective_message getlang = langsql.get_lang(message) if getlang == "id": wikipedia.set_lang("id") pagewiki = wikipedia.page(wiki) judul = pagewiki.title summary = pagewiki.summary if len(summary) >= 4096: summary = summary[:4000] + "..." message.reply_text("<b>{}</b>\n{}".format(judul, summary), parse_mode=ParseMode.HTML, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton(text=tl( update.effective_message, "Baca di Wikipedia"), url=pagewiki.url) ]])) else: first_name = update.effective_user.first_name buttons = InlineKeyboardMarkup( [[ InlineKeyboardButton( text="TAMBAHKAN AKU DIGRUP KAMU DONG! 🧸", url="https://t.me/Naylasilvianibot?startgroup=new") ], [ InlineKeyboardButton(text="SETELAN BAHASA! 📚", callback_data="main_setlang"), InlineKeyboardButton(text="KONEKSI GRUP! ⚙️", callback_data="main_connect") ], [ InlineKeyboardButton(text="SUPPORT GRUP! 💊", url="http://t.me/humangabutguys"), InlineKeyboardButton(text="UPDATE CHANNEL! 💎", url="https://t.me/captionanakmuda") ], [ InlineKeyboardButton( text="PERTOLOGAN! 🛠", url="https://t.me/Naylasilvianibot?start=help"), InlineKeyboardButton(text="DONASI BOT ✨", url="http://paypal.me/AIrvandi") ]]) update.effective_message.reply_text( tl(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( tl(update.effective_message, "Ada yang bisa saya bantu? 😊"))
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 unlock(bot: Bot, update: Update, args: List[str]) -> str: spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id, update.effective_message) if spam == True: return chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] if is_user_admin(chat, message.from_user.id): if len(args) >= 1: if args[0] in LOCK_TYPES: # Connection check conn = connected(bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = chat.title text = tl( update.effective_message, "Tidak terkunci *{}* untuk semua orang pada *{}*!" ).format(args[0], chat_name) else: if update.effective_message.chat.type == "private": send_message( update.effective_message, tl( update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM" )) return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title text = tl(update.effective_message, "Tidak terkunci *{}* untuk semua orang!").format( args[0]) sql.update_lock(chat.id, args[0], locked=False) send_message(update.effective_message, text, parse_mode="markdown") return "<b>{}:</b>" \ "\n#UNLOCK" \ "\n<b>Admin:</b> {}" \ "\nUnlocked <code>{}</code>.".format(html.escape(chat.title), mention_html(user.id, user.first_name), args[0]) elif args[0] in RESTRICTION_TYPES: # Connection check conn = connected(bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = chat.title text = tl( update.effective_message, "Tidak terkunci *{}* untuk semua orang pada *{}*!" ).format(args[0], chat_name) else: if update.effective_message.chat.type == "private": send_message( update.effective_message, tl( update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM" )) return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title text = tl(update.effective_message, "Tidak terkunci *{}* untuk semua orang!").format( args[0]) sql.update_restriction(chat.id, args[0], locked=False) """ members = users_sql.get_chat_members(chat.id) if args[0] == "messages": unrestr_members(bot, chat.id, members, media=False, other=False, previews=False) elif args[0] == "media": unrestr_members(bot, chat.id, members, other=False, previews=False) elif args[0] == "other": unrestr_members(bot, chat.id, members, previews=False) elif args[0] == "previews": unrestr_members(bot, chat.id, members) elif args[0] == "all": unrestr_members(bot, chat.id, members, True, True, True, True) """ send_message(update.effective_message, text, parse_mode="markdown") return "<b>{}:</b>" \ "\n#UNLOCK" \ "\n<b>Admin:</b> {}" \ "\nUnlocked <code>{}</code>.".format(html.escape(chat.title), mention_html(user.id, user.first_name), args[0]) else: send_message( update.effective_message, tl( update.effective_message, "Apa yang Anda coba untuk membuka kunci...? Coba /locktypes untuk daftar kunci yang dapat dikunci" )) else: send_message( update.effective_message, tl(update.effective_message, "Apa yang Anda coba untuk buka kunci...?")) return ""
def warn(user: User, chat: Chat, reason: str, message: Message, warner: User = None, conn=False) -> str: if is_user_admin(chat, user.id): return "" if warner: warner_tag = mention_html(warner.id, warner.first_name) else: warner_tag = tl(chat.id, "Filter peringatan otomatis.") limit, soft_warn, warn_mode = 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 not soft_warn: if not warn_mode: chat.unban_member(user.id) reply = tl(chat.id, "{} peringatan, {} telah ditendang!").format( limit, mention_html(user.id, user.first_name)) elif warn_mode == 1: chat.unban_member(user.id) reply = tl(chat.id, "{} peringatan, {} telah ditendang!").format( limit, mention_html(user.id, user.first_name)) elif warn_mode == 2: chat.kick_member(user.id) reply = tl(chat.id, "{} peringatan, {} telah diblokir!").format( limit, mention_html(user.id, user.first_name)) elif warn_mode == 3: message.bot.restrict_chat_member(chat.id, user.id, can_send_messages=False) reply = tl(chat.id, "{} peringatan, {} telah dibisukan!").format( limit, mention_html(user.id, user.first_name)) else: chat.kick_member(user.id) reply = tl(chat.id, "{} peringatan, {} telah diblokir!").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 = None 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(tl(chat.id, "Hapus peringatan"), callback_data="rm_warn({})".format(user.id)), InlineKeyboardButton(tl(chat.id, "Peraturan"), url="t.me/{}?start={}".format( dispatcher.bot.username, chat.id)) ]]) if num_warns + 1 == limit: if not warn_mode: action_mode = tl(chat.id, "tendang") elif warn_mode == 1: action_mode = tl(chat.id, "tendang") elif warn_mode == 2: action_mode = tl(chat.id, "blokir") elif warn_mode == 3: action_mode = tl(chat.id, "bisukan") reply = tl( chat.id, "{} punya {}/{} peringatan... Jika anda di peringati lagi maka kamu akan di {}!" ).format(mention_html(user.id, user.first_name), num_warns, limit, action_mode) else: reply = tl(chat.id, "{} punya {}/{} peringatan... Hati-hati!").format( mention_html(user.id, user.first_name), num_warns, limit) if reason: reply += tl(chat.id, "\nAlasan pada peringatan terakhir:\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: if conn: send_message_raw(chat.id, reply, reply_markup=keyboard, parse_mode=ParseMode.HTML) else: send_message_raw(chat.id, reply, reply_to_message_id=message.message_id, reply_markup=keyboard, parse_mode=ParseMode.HTML) #send_message(update.effective_message, reply, reply_markup=keyboard, parse_mode=ParseMode.HTML) except BadRequest as excp: if excp.message == "Reply message not found": # Do not reply if conn: message.bot.sendMessage(chat.id, reply, reply_markup=keyboard, parse_mode=ParseMode.HTML) else: try: message.bot.sendMessage( chat.id, reply, reply_to_message_id=message.message_id, reply_markup=keyboard, parse_mode=ParseMode.HTML, quote=False) except BadRequest: message.bot.sendMessage(chat.id, reply, reply_markup=keyboard, parse_mode=ParseMode.HTML, quote=False) #send_message(update.effective_message, reply, reply_markup=keyboard, parse_mode=ParseMode.HTML, quote=False) else: raise return log_reason
def start(update, context): if update.effective_chat.type == "private": args = context.args if len(args) >= 1: if args[0].lower() == "help": send_help(update.effective_chat.id, tl(update.effective_message, HELP_STRINGS)) elif args[0].lower() == "get_notes": update.effective_message.reply_text( tl(update.effective_message, "Anda sekarang dapat mengambil catatan di grup.")) 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) elif args[0][:4] == "wiki": wiki = args[0].split("-")[1].replace('_', ' ') message = update.effective_message getlang = langsql.get_lang(message) if getlang == "id": wikipedia.set_lang("id") pagewiki = wikipedia.page(wiki) judul = pagewiki.title summary = pagewiki.summary if len(summary) >= 4096: summary = summary[:4000] + "..." message.reply_text("<b>{}</b>\n{}".format(judul, summary), parse_mode=ParseMode.HTML, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton(text=tl( update.effective_message, "Baca di Wikipedia"), url=pagewiki.url) ]])) elif args[0][:6].lower() == "verify": chat_id = args[0].split("_")[1] verify_welcome(update, context, chat_id) else: first_name = update.effective_user.first_name buttons = InlineKeyboardMarkup( [[ InlineKeyboardButton( text="🎉 Me adicione em outro grupo!", url="https://t.me/{}?startgroup=new".format( context.bot.username)) ], [ InlineKeyboardButton(text="💭 Linguagem", callback_data="main_setlang"), InlineKeyboardButton(text="⚙️ Connect Group", callback_data="main_connect") ], [ InlineKeyboardButton(text="👥 Grupo de Suporte", url="https://t.me/EmiliaOfficial"), InlineKeyboardButton(text="🔔 Update Channel", url="https://t.me/AyraBotNews") ], [ InlineKeyboardButton( text="❓ Ajuda", url="https://t.me/{}?start=help".format( context.bot.username)), InlineKeyboardButton( text="💖 Donate", url="http://ayrahikari.github.io/donations.html") ]]) update.effective_message.reply_text(tl( update.effective_message, PM_START_TEXT).format(escape_markdown(first_name), escape_markdown(context.bot.first_name), OWNER_ID), disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN, reply_markup=buttons) else: update.effective_message.reply_text( tl(update.effective_message, "Ada yang bisa saya bantu? 😊"))