def mentionedList(groupID, text): mentionedList = [] listAT = re.findall(r'[@]\w*\b', text) listAT = list(set(listAT)) if len(listAT) > 0: for uname in listAT: username = re.split(r'[@]', uname)[1] userID = botFunctions.getMentionedUser(groupID, username.lower()) if userID != '': mentionedList.append(userID) listSUB = re.split('\W+', text) listSUB = list(set(listSUB)) if len(listSUB) > 0: for subname in listSUB: userID = botFunctions.getSubscribeUser(subname.lower()) if len(userID) > 0: for uID in userID: mentionedList.append(uID) mentionedList = list(set(mentionedList)) finalMentionedUsers = [] for getAllUsers in botFunctions.getAllUsers(groupID): for mentionUsers in mentionedList: if str(getAllUsers) == str(mentionUsers): finalMentionedUsers.append(mentionUsers) return finalMentionedUsers
def mentionAllVideo(bot, message): if botFunctions.checkAdmin(bot, message.chat.id, message.from_user.id) and message.chat.type != 'private': mentionedUser = botFunctions.getName(message.from_user) text = mentionedUser + ' @ <b>' + message.chat.title + '</b> : ' + message.caption for userid in botFunctions.getAllUsers(message.chat.id): if botFunctions.memberInTheGroup(bot, message.chat.id, userid): try: bot.send_video(chat_id=userid, data=message.video.file_id, caption=text, parse_mode='HTML') except: print('@all mention failed')
def groupAndSuperAdmin(bot, message): adminID = botFunctions.getAdmin() adminID.append(str(configuration.admin)) allUsersID = botFunctions.getAllUsers(message.chat.id) return list( set([i for i in adminID if i in allUsersID] + [ str(k.user.id) for k in bot.get_chat_administrators(message.chat.id) if not k.user.is_bot ]))
def pinnedPost(bot, message): mentionedUser = botFunctions.getName(message.from_user) text = mentionedUser + ' pinned a post @ <b>' + message.chat.title + '</b> : ' for userid in botFunctions.getAllUsers(message.chat.id): if botFunctions.memberInTheGroup(bot, message.chat.id, userid): try: bot.send_message(chat_id=userid, text=text, parse_mode='HTML') bot.forward_message( chat_id=userid, from_chat_id=message.chat.id, message_id=message.pinned_message.message_id) except: print('@all mention failed')
def mentionAllText(bot, message): if botFunctions.checkAdmin(bot, message.chat.id, message.from_user.id) and message.chat.type != 'private': mentionedUser = botFunctions.getName(message.from_user) text = mentionedUser + ' @ <b>' + message.chat.title + '</b> : ' + message.text for userid in botFunctions.getAllUsers(message.chat.id): if botFunctions.memberInTheGroup(bot, message.chat.id, userid): try: splitted_text = util.split_string(text, 3000) for text in splitted_text: bot.send_message(chat_id=userid, text=text, parse_mode='HTML') except: print('@all mention failed') if message.reply_to_message is not None: try: bot.forward_message(chat_id=userid, from_chat_id=message.chat.id, message_id=message.reply_to_message.message_id) except: print('@all forward failed')
def mentionAllPhoto(bot, message): if botFunctions.checkAdmin( bot, message.chat.id, message.from_user.id) and message.chat.type != 'private': mentionedUser = botFunctions.getName(message.from_user) text = mentionedUser + ' @ <b>' + message.chat.title + '</b> : mention @all in a photo' for userid in botFunctions.getAllUsers(message.chat.id): if botFunctions.memberInTheGroup(bot, message.chat.id, userid): try: bot.send_message(chat_id=userid, text=text, parse_mode='HTML') bot.send_photo(chat_id=userid, photo=message.photo[-1].file_id, caption=message.caption, parse_mode='HTML') except: print('@all mention failed')