def bancb(bot, update): uid = update.message.from_user.id gid = update.message.chat.id if not isAdmin(bot, uid, gid): return userid = update.message.reply_to_message.from_user.id if isAdmin(bot, userid, gid): bot.sendMessage(gid, text="You can't kick an administrator") else: db, cur = SetupSession() if BanUser(db, cur, userid, gid): #bot.kickChatMember(gid,userid) bot.sendMessage(gid, text="User wiped") db.close()
def modecb(bot, update, args): suid = update.message.from_user.id gid = update.message.chat_id # only an administrator can do that if not isAdmin(bot, suid, gid): return db, cur = SetupSession() try: username = update.message.reply_to_message.from_user.username userid = update.message.reply_to_message.from_user.id except AttributeError: bot.sendMessage( gid, text="Usage:\nquoting the user you want to change mode\n/mode +o|-o" ) return RegisterUser(db, cur, userid, username) if args[0] == "+o": # promote_to_admin if not AdminInDb(db, cur, userid, gid): bot.sendMessage(gid, text=username + " promoted to op") RegisterAdmin(db, cur, userid, gid) else: bot.sendMessage(gid, text=username + " already Op") elif args[0] == "-o": if AdminInDb(db, cur, userid, gid): bot.sendMessage(gid, text=username + " removed from op") RemoveAdmin(db, cur, userid, gid)
def opcb(bot, update): db, cur = SetupSession() username = update.message.from_user.username userid = update.message.from_user.id gid = update.message.chat_id RegisterUser(db, cur, userid, username) if AdminInDb(db, cur, userid, gid): print("promote to admin" + username)
def unbancb(bot, update): uid = update.message.from_user.id gid = update.message.chat.id if not isAdmin(bot, uid, gid): return userid = update.message.reply_to_message.from_user.id if isAdmin(bot, userid, gid): #remove admin rights print("rimuovi poteri") else: db, cur = SetupSession() if UnbanUser(db, cur, userid, gid): #bot.unbanChatMember(gid,userid) bot.sendMessage(gid, text="Ban removed") db.close
def NoBots(bot, update): gid = update.message.chat_id new_members = update.message.new_chat_members for user in new_members: username = user.username uid = user.id if uid != bot.id: if re.search("\w*bot$", username, re.IGNORECASE) != None: db, cur = SetupSession() if not BotInWhitelist(db, cur, gid, uid): bot.sendMessage(gid, text="Bot not in whitelist") bot.kickChatMember(gid, uid) db.close() else: bot.sendMessage(gid, text="Bot in whitelist") db.close()