Esempio n. 1
0
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')
Esempio n. 2
0
def welcomemessage(bot, message):
    if message.chat.type == 'private':
        try:
            bot.send_message(
                chat_id=message.from_user.id,
                text="Please use this command inside the groups " +
                emojiList.successFaceIcon)
        except:
            print('welcome message private send failed')
    else:
        if botFunctions.checkAdmin(bot, message.chat.id, message.from_user.id):
            userID = message.from_user.id
            subList = re.split(r'/welcomemessage\W', message.text, 1)
            if len(subList) == 2:
                if subList[1] != '':
                    welcomeMessage = subList[1]
                    if botFunctions.updateWelcomeMessage(
                            welcomeMessage, message.chat.id) == 'success':
                        try:
                            bot.send_message(
                                chat_id=userID,
                                text='Welcome Message successfully changed ' +
                                emojiList.successFaceIcon)
                        except:
                            print(
                                'Welcome Message successfully changed failed')
                    else:
                        try:
                            bot.send_message(
                                chat_id=userID,
                                text=
                                'Welcome Message successfully changing failed '
                                + emojiList.failFaceIcon)
                        except:
                            print(
                                'Welcome Message successfully changing failed')
                else:
                    try:
                        bot.send_message(
                            chat_id=userID,
                            text='Welcome Message cannot be empty ' +
                            emojiList.failFaceIcon)
                    except:
                        print('Welcome Message cannot be empty')
            elif len(subList) == 1:
                try:
                    bot.send_message(
                        chat_id=userID,
                        text='Please add a Valid Welcome Message ' +
                        emojiList.successFaceIcon)
                except:
                    print('valid welcome message failed')
Esempio n. 3
0
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')
Esempio n. 4
0
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')
Esempio n. 5
0
def commandPermissionChange(bot, message, permissionColumn, permissionName):
    if message.chat.type == 'private':
        try:
            bot.send_message(
                chat_id=message.from_user.id,
                text="Please use this command inside the groups " +
                emojiList.successFaceIcon)
        except:
            print(permissionName + ' private send failed')
    else:
        if botFunctions.checkAdmin(bot, message.chat.id, message.from_user.id):
            userID = message.from_user.id
            subList = re.split('\W+', message.text, re.U)
            if len(subList) == 3:
                if subList[2] != '':
                    subname = subList[2].lower()
                    if subname == "false":
                        permission = False
                    elif subname == "true":
                        permission = True
                    else:
                        try:
                            bot.send_message(chat_id=userID,
                                             text=permissionName +
                                             ' must be True or False ' +
                                             emojiList.failFaceIcon)
                        except:
                            print(permissionName + ' must be True or False')
                        return
                    if botFunctions.changePermissionInGroups(
                            permission, permissionColumn, message.chat.id):
                        try:
                            bot.send_message(chat_id=userID,
                                             text=permissionName +
                                             ' successfully changed ' +
                                             emojiList.successFaceIcon)
                        except:
                            print(permissionName +
                                  ' successfully changed failed')
                    else:
                        try:
                            bot.send_message(chat_id=userID,
                                             text=permissionName +
                                             ' successfully changing failed ' +
                                             emojiList.failFaceIcon)
                        except:
                            print(permissionName +
                                  ' successfully changing failed')
                else:
                    try:
                        bot.send_message(chat_id=userID,
                                         text=permissionName +
                                         ' cannot be empty ' +
                                         emojiList.failFaceIcon)
                    except:
                        print(permissionName + ' cannot be empty')
            elif len(subList) == 2:
                try:
                    bot.send_message(chat_id=userID,
                                     text='Please add a/an ' + permissionName +
                                     ' ' + emojiList.successFaceIcon)
                except:
                    print(permissionName + ' not found')
            else:
                try:
                    bot.send_message(chat_id=userID,
                                     text='Can add only one permission ' +
                                     emojiList.failFaceIcon)
                except:
                    print('Can add only one permission same time')