def permapin(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 conn = connected(context.bot, update, chat, user.id, need_admin=False) 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": 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, data_type, content, buttons = get_message_type(message) tombol = build_keyboard_alternate(buttons) try: message.delete() except BadRequest: pass if str(data_type) in ('Types.BUTTON_TEXT', 'Types.TEXT'): try: sendingmsg = context.bot.send_message( chat_id, text, parse_mode="markdown", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(tombol)) except BadRequest: context.bot.send_message( chat_id, tl( update.effective_message, "Teks markdown salah!\nJika anda tidak tahu apa itu markdown, silahkan ketik `/markdownhelp` pada PM." ), parse_mode="markdown") return else: sendingmsg = ENUM_FUNC_MAP[str(data_type)]( chat_id, content, caption=text, parse_mode="markdown", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(tombol)) try: context.bot.pinChatMessage(chat_id, sendingmsg.message_id) except BadRequest: send_message( update.effective_message, tl(update.effective_message, "Saya tidak punya akses untuk pin pesan!"))
def permapin(bot: Bot, update: Update): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] 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!" ) conn = connected(bot, update, chat, user.id, need_admin=False) 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_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, data_type, content, buttons = get_message_type(message) tombol = build_keyboard_alternate(buttons) if True: try: message.delete() except: update.effective_message.reply_text("Saya bukan admin!") return if str(data_type) in ('Types.BUTTON_TEXT', 'Types.TEXT'): try: sendingmsg = bot.send_message( chat_id, text, parse_mode="markdown", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(tombol)) except BadRequest: bot.send_message( chat_id, "Teks markdown salah!\nJika anda tidak tahu apa itu markdown, silahkan ketik `/markdownhelp` pada PM.", parse_mode="markdown") return else: sendingmsg = ENUM_FUNC_MAP[str(data_type)]( chat_id, content, caption=text, parse_mode="markdown", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(tombol)) bot.pinChatMessage(chat_id, sendingmsg.message_id)
def echo(bot: Bot, update: Update): message = update.effective_message chat_id = update.effective_chat.id try: message.delete() except BadRequest: pass # Advanced text, data_type, content, buttons = get_message_type(message) tombol = build_keyboard_alternate(buttons) if str(data_type) in ('Types.BUTTON_TEXT', 'Types.TEXT'): try: if message.reply_to_message: bot.send_message(chat_id, text, parse_mode="markdown", reply_to_message_id=message.reply_to_message.message_id, disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(tombol)) else: bot.send_message(chat_id, text, quote=False, disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(tombol)) except BadRequest: bot.send_message(chat_id, "Teks markdown salah!\nJika anda tidak tahu apa itu markdown, silahkan ketik `/markdownhelp` pada PM.", parse_mode="markdown") return