def connected(bot, update, chat, user_id, need_admin=True): user = update.effective_user spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id) if spam == True: return if chat.type == chat.PRIVATE and sql.get_connected_chat(user_id): conn_id = sql.get_connected_chat(user_id).chat_id getstatusadmin = bot.get_chat_member(conn_id, update.effective_message.from_user.id) isadmin = getstatusadmin.status in ('administrator', 'creator') ismember = getstatusadmin.status in ('member') isallow = sql.allow_connect_to_chat(conn_id) if (isadmin) or (isallow and ismember) or (user.id in SUDO_USERS) or (user.id in DEV_USERS): if need_admin == True: if getstatusadmin.status in ('administrator', 'creator') or user_id in SUDO_USERS or user.id in DEV_USERS: return conn_id else: send_message(update.effective_message, "You must be an admin in the connected group!") raise Exception("Not admin!") else: return conn_id else: send_message(update.effective_message, "The group changed the connection rights or you are no longer an admin.\nI've disconnected you.") disconnect_chat(bot, update) raise Exception("Not admin!") else: return False
def connected(bot, update, chat, user_id, need_admin=True): user = update.effective_user msg = update.effective_message if chat.type == chat.PRIVATE and sql.get_connected_chat(user_id): conn_id = sql.get_connected_chat(user_id).chat_id getstatusadmin = bot.get_chat_member(conn_id, msg.from_user.id) isadmin = getstatusadmin.status in ADMIN_STATUS ismember = getstatusadmin.status in MEMBER_STAUS isallow = sql.allow_connect_to_chat(conn_id) if isadmin or (isallow and ismember) or (user.id in SUDO_USERS) or ( user.id in DEV_USERS): if need_admin is True: if getstatusadmin.status in ADMIN_STATUS or user_id in SUDO_USERS or user.id in DEV_USERS: return conn_id else: send_message( msg, "You must be an admin in the connected group!") raise Exception("Not admin!") else: return conn_id else: send_message( msg, "The group changed the connection rights or you are no longer an admin.\n" "I've disconnected you.") disconnect_chat(bot, update) raise Exception("Not admin!") else: return False
def connected(bot, update, chat, user_id, need_admin=True): user = update.effective_user spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id) if spam == True: return if chat.type == chat.PRIVATE and sql.get_connected_chat(user_id): conn_id = sql.get_connected_chat(user_id).chat_id getstatusadmin = bot.get_chat_member( conn_id, update.effective_message.from_user.id) isadmin = getstatusadmin.status in ('administrator', 'creator') ismember = getstatusadmin.status in ('member') isallow = sql.allow_connect_to_chat(conn_id) if (isadmin) or (isallow and ismember) or (user.id in SUDO_USERS) or ( user.id in DEV_USERS): if need_admin == True: if getstatusadmin.status in ( 'administrator', 'creator' ) or user_id in SUDO_USERS or user.id in DEV_USERS: return conn_id else: send_message(update.effective_message, "Bağlı qrupda bir admin olmalısınız!") raise Exception("Not admin!") else: return conn_id else: send_message( update.effective_message, "Qrup əlaqə hüquqlarını dəyişdirdi, yada artıq idarəçi deyilsiniz.\nSizlə əlaqəni kəsdim." ) disconnect_chat(bot, update) raise Exception("Not admin!") else: return False