def disconnect_chat(bot, update): 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': disconnection_status = sql.disconnect( update.effective_message.from_user.id) if disconnection_status: sql.disconnected_chat = send_message( update.effective_message, languages.tl(update.effective_message, "Terputus dari obrolan!")) else: send_message( update.effective_message, languages.tl(update.effective_message, "Anda tidak terkoneksi!")) else: send_message( update.effective_message, languages.tl(update.effective_message, "Penggunaan terbatas hanya untuk PM"))
def connect_button(bot: Bot, update: Update) -> str: query = update.callback_query chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] connect_match = re.match(r"connect\((.+?)\)", query.data) disconnect_match = query.data == "connect_disconnect" clear_match = query.data == "connect_clear" connect_close = query.data == "connect_close" if connect_match: target_chat = connect_match.group(1) getstatusadmin = bot.get_chat_member(target_chat, query.from_user.id) isadmin = getstatusadmin.status in ('administrator', 'creator') ismember = getstatusadmin.status in ('member') isallow = sql.allow_connect_to_chat(target_chat) if (isadmin) or (isallow and ismember) or (user.id in SUDO_USERS): connection_status = sql.connect(query.from_user.id, target_chat) if connection_status: conn_chat = dispatcher.bot.getChat( connected(bot, update, chat, user.id, need_admin=False)) chat_name = conn_chat.title query.message.edit_text(languages.tl( update.effective_message, "Berhasil tersambung ke *{}*. Gunakan /connection untuk informasi perintah apa saja yang tersedia." ).format(chat_name), parse_mode=ParseMode.MARKDOWN) sql.add_history_conn(user.id, str(conn_chat.id), chat_name) else: query.message.edit_text( languages.tl(update.effective_message, "Koneksi gagal!")) else: bot.answer_callback_query( query.id, languages.tl(update.effective_message, "Sambungan ke obrolan ini tidak diizinkan!"), show_alert=True) elif disconnect_match: disconnection_status = sql.disconnect(query.from_user.id) if disconnection_status: sql.disconnected_chat = query.message.edit_text( languages.tl(update.effective_message, "Terputus dari obrolan!")) else: bot.answer_callback_query(query.id, languages.tl(update.effective_message, "Anda tidak terkoneksi!"), show_alert=True) elif clear_match: sql.clear_history_conn(query.from_user.id) query.message.edit_text( languages.tl(update.effective_message, "Riwayat yang terhubung telah dihapus!")) elif connect_close: query.message.edit_text( languages.tl(update.effective_message, "Closed.\nTo open again, type /connect")) else: connect_chat(bot, update, [])
def disconnect_chat(update, context): if update.effective_chat.type == 'private': disconnection_status = sql.disconnect( update.effective_message.from_user.id) if disconnection_status: sql.disconnected_chat = send_message( update.effective_message, languages.tl(update.effective_message, "Terputus dari obrolan!")) else: send_message( update.effective_message, languages.tl(update.effective_message, "Anda tidak terkoneksi!")) else: send_message( update.effective_message, languages.tl(update.effective_message, "Penggunaan terbatas hanya untuk PM"))
def disconnect_chat(bot, update): 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': disconnection_status = sql.disconnect( update.effective_message.from_user.id) if disconnection_status: sql.disconnected_chat = update.effective_message.reply_text( "Terputus dari obrolan!") else: update.effective_message.reply_text( "Memutus sambungan tidak berhasil!") else: update.effective_message.reply_text( "Penggunaan terbatas hanya untuk PM")