예제 #1
0
def check_updates(update):
    chat = chat_object(update)
    user = user_object(update)
    date = datetime.datetime.utcnow().isoformat()
    if chat.type == "supergroup" or chat.type == "group":
        data = [(update.update_id, chat.id, user.id, date)]
        GroupRepository().insert_updates(data)
예제 #2
0
def init(update, context):
    bot = context.bot
    chat = chat_object(update)
    languages(update, context)
    record_arabic = GroupRepository.SET_ARABIC
    record_chinese = GroupRepository.SET_CHINESE
    record_cirillic = GroupRepository.SET_CIRILLIC
    record_no_user_photo = GroupRepository.SET_USER_PROFILE_PICT
    record_silence = GroupRepository.SET_SILENCE
    record_block_channel = GroupRepository.SENDER_CHAT_BLOCK
    record_zoophile = GroupRepository.ZOOPHILE_FILTER

    data = [(0, 1, chat.id)]
    GroupRepository().set_block_entry(data)
    update_db_settings(update, record_arabic, False)
    update_db_settings(update, record_chinese, False)
    update_db_settings(update, record_cirillic, False)
    update_db_settings(update, record_no_user_photo, False)
    update_db_settings(update, record_silence, False)
    update_db_settings(update, record_block_channel, False)
    update_db_settings(update, record_zoophile, False)
    buttons = []
    buttons.append(
        InlineKeyboardButton('❌ Remove Shield', callback_data='removeShield'))
    menu = build_menu(buttons, 1)

    bot.set_chat_permissions(update.effective_chat.id, PERM_FALSE)
    bot.send_message(chat.id,
                     languages.shield_on,
                     reply_markup=InlineKeyboardMarkup(menu),
                     parse_mode='HTML')
    logs_text = '🛡Shield Activated in {} <code>[{}]</code>'.format(
        chat.title, chat.id)
    telegram_loggers(update, context, logs_text)
예제 #3
0
def init(update,context):
    chat = chat_object(update)
    get_group = GroupRepository().getById(chat.id)
    max_warn = get_group['max_warn']
    current_time = datetime.datetime.utcnow().isoformat()
    default_warn = 1
    languages(update,context)
    if update.message.reply_to_message:
        reason = update.message.text[5:]
        user = user_reply_object(update)
        get_user = UserRepository().getUserByGroup([user.id,chat.id])
        warn_count = get_user['warn_count'] if get_user is not None else 0
        if warn_count != max_warn:
            buttons = []
            buttons.append(InlineKeyboardButton('➖ 1', callback_data='downWarn'))
            buttons.append(InlineKeyboardButton('➕ 1', callback_data='upWarn'))
            buttons.append(InlineKeyboardButton(languages.button_remove, callback_data='removeWarn'))
            menu = build_menu(buttons,3)
            if get_user:
                default_warn_count = 0
                username = "******"+user.username
                data = [(username,current_time,user.id)]
                UserRepository().update(data)
                data_mtm = [(user.id, chat.id, default_warn_count)]
                UserRepository().add_into_mtm(data_mtm)
                data_warn = [(user.id,chat.id)]
                UserRepository().updateWarn(data_warn)
                if reason:
                    msg = languages.warn_with_reason.format(mention_html(user.id, user.first_name),chat.title,chat.id,reason)
                    update.message.reply_to_message.reply_text(msg, reply_markup=InlineKeyboardMarkup(menu),parse_mode='HTML')
                else:
                    msg = languages.warn_user.format(mention_html(user.id, user.first_name),chat.title,chat.id)
                    update.message.reply_to_message.reply_text(msg, reply_markup=InlineKeyboardMarkup(menu),parse_mode='HTML')
                log_txt = "‼️ #Log {} was warned\nin the group: {} <code>[{}]</code>".format(mention_html(user.id, user.first_name),chat.title,chat.id)
                if reason:
                    log_txt = "‼️ #Log {} was warned\nin the group: {} <code>[{}]</code>\nReason: {}".format(mention_html(user.id, user.first_name),chat.title,chat.id,reason)
                telegram_loggers(update,context,log_txt)
            else:
                username = "******"+user.username
                data = [(user.id,username,current_time,current_time)]
                UserRepository().add(data)
                data_mtm = [(user.id, chat.id, default_warn)]
                UserRepository().add_into_mtm(data_mtm)
                if reason:
                    message(update,context,languages.warn_with_reason.format(username,chat.title,chat.id,reason))
                else:
                    message(update,context,languages.warn_user.format(username,chat.title,chat.id))
                log_txt = "‼️ #Log {} was warned\nin the group: {} <code>[{}]</code>".format(mention_html(user.id, user.first_name),chat.title,chat.id)
                if reason:
                    log_txt = "‼️ #Log {} was warned\nin the group: {} <code>[{}]</code>\nReason: {}".format(mention_html(user.id, user.first_name),chat.title,chat.id,reason)
                telegram_loggers(update,context,log_txt)
        else:
            ban_user_reply(update,context)
            buttons = []
            buttons.append(InlineKeyboardButton('Remove', callback_data='removeWarn'))
            menu = build_menu(buttons,2)
            msg = languages.warn_user_max.format(user.username,chat.title)
            update.message.reply_to_message.reply_text(msg, reply_markup=InlineKeyboardMarkup(menu),parse_mode='HTML')
    else:
        message(update,context,languages.error_response_user_msg)
예제 #4
0
def init(update, context):
    user = user_reply_object(update)
    chat = chat_object(update)
    user_db = UserRepository().getById(user.id)
    get_warn = UserRepository().getUserByGroup([user.id, chat.id])
    default_warn = 0
    if user_db:
        username = "******" + user.username
        data = [(username, user.id)]
        UserRepository().update(data)
        warn_count = get_warn['warn_count']
        data_mtm = [(user.id, chat.id, default_warn)]
        UserRepository().add_into_mtm(data_mtm)
        msg = Strings.USER_INFO.format(id=user.id,
                                       username=user.username,
                                       chat=chat.title,
                                       warn=warn_count)
        PrivateMessage(update, context, msg)
    else:
        username = "******" + user.username
        data = [(user.id, username, default_warn)]
        UserRepository().add(data)
        data_mtm = [(user.id, chat.id, default_warn)]
        UserRepository().add_into_mtm(data_mtm)
        msg = Strings.USER_INFO.format(id=user.id,
                                       username=user.username,
                                       chat=chat.title,
                                       warn=default_warn)
        PrivateMessage(update, context, msg)
예제 #5
0
def init(update, context):
    chat = chat_object(update)
    msg = update.message.text[8:].strip()
    if msg != "":
        data = [(msg, chat.id)]
        GroupRepository().insert_badword(data)
        message(update, context, languages.badlist_add.format(msg))
    else:
        message(update, context, languages.badlist_add_empty)
def init(update, context):
    bot = context.bot
    chat = chat_object(update)
    link = bot.export_chat_invite_link(chat.id)
    message(
        update, context,
        "An invitation link was generated for the chat <b>{}</b>\nThe invitation was sent in <i>private</i>"
        .format(chat.title))
    PrivateMessage(update, context,
                   "Chat: {}\nInvite Link: {}".format(chat.title, link))
예제 #7
0
파일: exit.py 프로젝트: mdnmdn/nebula8
def init(update, context):
    bot = context.bot
    chat = chat_object(update)
    bot.leaveChat(update.message.chat_id)
    telegram_loggers(
        update, context,
        "#Log the bot has left the chat <code>{}</code>\nby operator <code>{}</code>"
        .format(chat.id, update.message.from_user.id))
    formatter = "Il bot è uscito dalla chat {} e il comando è stato eseguito da: {}".format(
        chat.id, update.message.from_user.id)
    sys_loggers("[BOT_EXIT_LOGS]", formatter, False, False, True)
예제 #8
0
def init(update, context):
    chat = chat_object(update)
    link = "https://t.me/{}".format(chat.username)
    row = CommunityRepository().getById(chat.id)
    if row:
        data = [(chat.title, chat.id)]
        CommunityRepository().update(data)
        message(update, context, "Update Community")
    else:
        data = [(chat.title, chat.id, link)]
        CommunityRepository().add(data)
        message(update, context, "Insert Community")
예제 #9
0
def init(update, context):
    bot = context.bot
    chat = chat_object(update)
    #GroupRepository.remove(chat.id)
    bot.leaveChat(update.message.chat_id)
    messageWithId(
        update, context, Config.DEFAULT_LOG_CHANNEL,
        "#Log the bot has left the chat <code>{}</code>\nby operator <code>{}</code>"
        .format(chat.id, update.message.from_user.id))
    formatter = "Il bot è uscito dalla chat {} e il comando è stato eseguito da: {}".format(
        chat.id, update.message.from_user.id)
    sys_loggers("[BOT_EXIT_LOGS]", formatter, False, False, True)
예제 #10
0
def badlist(update, context):
    chat = chat_object(update)
    languages(update, context)
    rows = GroupRepository().get_badwords_group(chat.id)
    if rows:
        string = ""
        for row in rows:
            string += "▪️ {}\n".format(row['word'])
        message(update, context,
                languages.badlist_text.format(chat.title, string))
    else:
        message(update, context, languages.badlist_empty)
예제 #11
0
def global_report(update, context):
    bot = context.bot
    chat = chat_object(update)
    languages(update, context)
    if update.effective_message.reply_to_message:
        message(update, context, languages.delete_error_msg)
    else:
        link = bot.export_chat_invite_link(chat.id)
        msg = "#GlobalReport\nChatId: {}\nChat: {}\nLink: {}".format(
            chat.id, chat.title, link)
        msg_report = languages.global_report_msg
        staff_loggers(update, context, msg)
        message(update, context, msg_report)
예제 #12
0
def init(update, context):
    user = user_reply_object(update)
    chat = chat_object(update)
    get_user = UserRepository().getUserByGroup([user.id, chat.id])
    get_group = GroupRepository().getById(chat.id)
    warn_count = get_user['warn_count'] if get_user is not None else 0
    max_warn = get_group['max_warn']
    default_warn = 1

    if warn_count != max_warn:
        if get_user:
            default_warn_count = 0
            username = "******" + user.username
            data = [(username, user.id)]
            UserRepository().update(data)
            data_mtm = [(user.id, chat.id, default_warn_count)]
            UserRepository().add_into_mtm(data_mtm)
            data_warn = [(user.id, chat.id)]
            UserRepository().updateWarn(data_warn)
            message(
                update, context,
                "{} was warned by the group {}".format(username, chat.title))
            log_txt = "#Log {} was warned by the group {}".format(
                username, chat.title)
            telegram_loggers(update, context, log_txt)
        else:
            username = "******" + user.username
            data = [(user.id, username, default_warn)]
            UserRepository().add(data)
            data_mtm = [(user.id, chat.id, default_warn)]
            UserRepository().add_into_mtm(data_mtm)
            message(
                update, context,
                "{} was warned by the group {}".format(username, chat.title))
            log_txt = "#Log {} was warned by the group {}".format(
                username, chat.title)
            telegram_loggers(update, context, log_txt)
    else:
        ban_user_reply(update, context)
        message(
            update, context,
            "User @{} has reached the maximum number\n of warns in the {} group and has been banned"
            .format(user.username, chat.title))
예제 #13
0
def check_status(update,context):
    chat = chat_object(update)
    user = user_object(update)
    get_superban_user_id = update.effective_user.id
    user_db = UserRepository().getById(user.id)
    get_superban = SuperbanRepository().getById(get_superban_user_id)
    default_count_warn = 0
    get_group = GroupRepository().getById(chat.id)
    user_photo = user.get_profile_photos(user.id)
    user_set_photo = get_group['set_user_profile_picture']
    #warn_count = user_db['warn_count'] if user_db is not None else 0
    #max_warn = get_group['max_warn']
    #if warn_count == max_warn:
        #ban_user(update,context)
        #msg = "#Automatic Handler\n<code>{}</code> has reached the maximum number of warns"
        #message(update,context,msg.format(user.id))

    if user.username is None or "":
        kick_user(update, context)
        msg = "#Automatic Handler\n<code>{}</code> set a username! You were kicked for safety!"
        message(update,context,msg.format(user.id))
    if user_photo.total_count == 0 and user_set_photo == 1:
        kick_user(update, context)
        msg = "#Automatic Handler\n<code>{}</code> set a profile picture! You were kicked for safety!"
        message(update,context,msg.format(user.id))
    if user_db:
        username = "******"+user.username
        data = [(username,user.id)]
        UserRepository().update(data)
        data_mtm = [(user.id, chat.id, default_count_warn)]
        UserRepository().add_into_mtm(data_mtm)
    if user_db is None or "":
        username = "******"+user.username
        default_warn = 0
        data = [(user.id,username,default_warn)]
        UserRepository().add(data)
        data_mtm = [(user.id, chat.id, default_count_warn)]
        UserRepository().add_into_mtm(data_mtm)
    if get_superban:
        msg = 'I got super banned <a href="tg://user?id={}">{}</a>'.format(user.id,user.first_name)
        message(update,context,msg)
        delete_message(update,context)
        ban_user(update,context)
예제 #14
0
def init(update,context):
    bot = context.bot
    chat = chat_object(update)
    if chat.type == 'supergroup':
        row = CommunityRepository().getById(chat.id)
        if row:
            record = GroupRepository.SET_COMMUNITY
            default_community = 1
            data = [(chat.title,chat.id)]
            data_group = [(default_community, chat.id)]
            CommunityRepository().update(data)
            GroupRepository().update_group_settings(record,data_group)
            message(update,context,"I updated the community on the database")
        else:
            buttons = []
            buttons.append(InlineKeyboardButton('IT', callback_data='commIT'))
            buttons.append(InlineKeyboardButton('EN', callback_data='commEN'))
            buttons.append(InlineKeyboardButton('Close', callback_data='closeMenu'))
            menu = build_menu(buttons,2)
            bot.send_message(chat_id=update.effective_chat.id,text="Please select the language of the community",reply_markup=InlineKeyboardMarkup(menu))
    else:
        message(update,context,"Attention! this command can only be used in public supergroups!")
예제 #15
0
def init(update, context):
    bot = context.bot
    reply = update.message.reply_to_message
    if reply is not None:
        user_status = reply_member_status_object(update, context)
        if user_status.status == 'kicked':
            chat = chat_object(update)
            user = user_reply_object(update)
            message(
                update, context,
                "the ban for the user {} <code>[{}]</code> has been removed".
                format(mention_html(user.id, user.first_name), user.id))
            bot.unban_chat_member(chat.id, user.id)
        else:
            user = user_reply_object(update)
            message(
                update, context,
                "the user {} <code>[{}]</code> is not banned".format(
                    mention_html(user.id, user.first_name), user.id))
    else:
        message(update, context,
                "This command should be used in response to a user!")
예제 #16
0
def init(update, context):
    try:
        languages(update, context)
        if update.message.reply_to_message:
            bot = bot_object(update, context)
            chat = chat_object(update)
            user = user_reply_object(update)
            bot.promoteChatMember(chat.id,
                                  user.id,
                                  can_change_info=True,
                                  can_delete_messages=True,
                                  can_invite_users=True,
                                  can_restrict_members=True,
                                  can_pin_messages=True,
                                  can_promote_members=True)
        else:
            message(update, context, languages.delete_error_msg)
    except BadRequest:
        message(
            update,
            context,
            text=
            "Non ho il permesso per promuovere questo utente come admin!\nPuoi darmi questo permesso spuntando il flag:\n <i>Aggiungere Amministratori</i>"
        )
예제 #17
0
def check_status(update, context):
    bot = context.bot
    chat_title = update.effective_chat.title
    chat_id = update.effective_chat.id
    get_bot = bot.getChatMember(chat_id, bot.id)
    get_group = GroupRepository().getById(chat_id)
    record_title = GroupRepository.SET_GROUP_NAME
    entities = list(update.effective_message.entities)
    get_chat_tg = bot.getChat(chat_id=chat_id)
    linked_chat = get_chat_tg.linked_chat_id
    group_members_count = update.effective_chat.get_member_count()
    #buttons = list(update.effective_message.reply_markup.inline_keyboard)
    """
    This function updates the group id on the database
    when a group changes from group to supergroup
    """
    if update.effective_message.migrate_from_chat_id is not None:
        old_chat_id = update.message.migrate_from_chat_id
        new_chat_id = update.message.chat.id
        data = [(new_chat_id, old_chat_id)]
        GroupRepository().update(data)
        message(
            update, context,
            "<b>#Automatic handler:</b>\nThe chat has been migrated to <b>supergroup</b> the bot has made the modification on the database.\n<i>It is necessary to put the bot admin</i>"
        )
        debug_channel(
            update, context,
            "[DEBUG_LOGGER] La chat {} è stata modifica da Gruppo a Supergruppo il suo nuovo id è: {}"
            .format(old_chat_id, new_chat_id))
    """
    This function saves the group to the database
    when the bot is added as soon as a group or supergroup is created
    """
    if update.effective_message.group_chat_created == True or update.effective_message.supergroup_chat_created == True:
        welcome_bot(update, context)
        l_txt = "#Log <b>Bot added to group</b> {}\nId: <code>{}</code>".format(
            chat_title, chat_id)
        telegram_loggers(update, context, l_txt)
    """
    This feature changes the chat title
    on the database when it is changed
    """
    if update.effective_message.new_chat_title:
        data = [(chat_title, chat_id)]
        GroupRepository().update_group_settings(record_title, data)
        debug_channel(
            update, context,
            "[DEBUG_LOGGER] La chat <code>[{}]</code> ha cambiato titolo".
            format(chat_id))
    """
    When a chat room changes group image it is saved to the webserver
    like this: example.com/group_photo/-100123456789.jpg (url variable)
    """
    if update.effective_message.new_chat_photo:
        chat = chat_object(update)
        if chat.type == "supergroup" or chat.type == "group":
            file_id = update.message.new_chat_photo[2].file_id
            newFile = bot.get_file(file_id)
            newFile.download(
                '/var/www/naos.hersel.it/group_photo/{}.jpg'.format(chat_id))
            url = "https://naos.hersel.it/group_photo/{}.jpg".format(chat_id)
            data = [(url, chat_id)]
            record = GroupRepository.SET_GROUP_PHOTO
            GroupRepository().update_group_settings(record, data)
            formatter = "New Url: {}".format(url)
            sys_loggers("[UPDATE_GROUP_PHOTO_LOGS]", formatter, False, True)
            debug_channel(
                update, context,
                "[DEBUG_LOGGER] La chat <code>[{}]</code> ha cambiato foto\nIl suo nuovo URL è: {}"
                .format(chat_id, url))
    """
    This function saves the number
    of users in the group in the database
    """
    if group_members_count > 0:
        record_count = GroupRepository.SET_GROUP_MEMBERS_COUNT
        data = [(group_members_count, chat_id)]
        GroupRepository().update_group_settings(record_count, data)
    """
    This function checks if the group is present in the blacklist
    if it is present the bot leaves the group
    """
    if check_group_blacklist(update) == True:
        message(
            update, context,
            "<b>#Automatic handler:</b>\nThe group is blacklisted the bot will automatically exit the chat"
        )
        log_txt = "#Log <b>Bot removed from group</b> {}\nId: <code>{}</code>".format(
            chat_title, chat_id)
        telegram_loggers(update, context, log_txt)
        time.sleep(2)
        bot.leave_chat(chat_id)
        debug_channel(
            update, context,
            "[DEBUG_LOGGER] Il bot è stato rimosso dalla chat <code>[{}]</code> perchè il gruppo è in Blacklist"
            .format(chat_id))
    """
    This function checks the
    badwords of the group
    """
    if check_group_badwords(update) == True:
        user = user_object(update)
        bot.delete_message(update.effective_message.chat_id,
                           update.message.message_id)
        message(
            update, context,
            "<b>#Automatic handler:</b>\n<code>{}</code> You used a forbidden word!"
            .format(user.id))
        debug_channel(
            update, context,
            "[DEBUG_LOGGER] L'utente <code>{}</code> ha usato una parola proibita"
            .format(user.id))
    """
    This function checks if there is a badword in a link
    """
    if entities is not None:
        for x in entities:
            if x['url'] is not None:
                bad_word = x['url']
                row = GroupRepository().get_group_badwords([bad_word, chat_id])
                if row:
                    user = user_object(update)
                    bot.delete_message(update.effective_message.chat_id,
                                       update.message.message_id)
                    message(
                        update, context,
                        "<b>#Automatic handler:</b>\n<code>{}</code> You used a forbidden word!"
                        .format(user.id))
    """
    This function checks if messages
    are arriving from a channel and deletes them
    """
    if update.effective_message.sender_chat and get_group[
            'sender_chat_block'] == 1:
        sender_chat_obj = update.effective_message.sender_chat

        if update.effective_message.voice_chat_started:
            return
        elif update.effective_message.voice_chat_ended:
            return
        elif get_chat_tg.type == "channel":
            return
        elif sender_chat_obj.id == linked_chat:
            return
        else:
            message(
                update, context,
                "<b>#Automatic Handler:</b>\nIn this group <code>[{}]</code> it is not allowed to write with the\n{} <code>[{}]</code> channel"
                .format(chat_id, sender_chat_obj.title, sender_chat_obj.id))
            bot.delete_message(update.effective_message.chat_id,
                               update.message.message_id)
    """
    This function checks that the bot is an administrator
    and sends an alert
    """
    if get_bot.status == 'member':
        message(
            update, context,
            "I am not an administrator of this group, you have to make me an administrator to function properly!"
        )
        debug_channel(
            update, context,
            "[DEBUG_LOGGER] Il bot non è un amministratore della chat {}".
            format(chat_id))
    """
    This function is used to filter messages with spoiler type
    and delete them if the group owner puts the block at 1
    """
    for a in entities:
        type_entities = a['type']
        if type_entities is not None:
            if type_entities == "spoiler" and get_group['spoiler_block'] == 1:
                message(
                    update, context,
                    "<b>#Automatic Handler:</b>\nIn this chat the use of spoilers is not allowed!"
                )
                bot.delete_message(update.effective_message.chat_id,
                                   update.message.message_id)
    #TODO NONETYPE PROBLEM
    """if buttons is not None:
        for url in buttons:
            if url[0]['url'] is not None:
                bad_word = url[0]['url'] or url[0]['text']
                row = GroupRepository().get_group_badwords([bad_word, chat_id])
                if row:
                    user = user_object(update)
                    bot.delete_message(update.effective_message.chat_id, update.message.message_id)
                    message(update,context,"<b>#Automatic handler:</b>\n<code>{}</code> You used a forbidden word!".format(user.id))
    else:
        print("no button")"""
    """
    Voice audio blocking
    """
    if update.effective_message.voice is not None and get_group[
            'set_no_vocal'] == 1:
        message(
            update, context,
            "<b>#Automatic Handler:</b>\nIs not allowed to use vocals in this chat!"
        )
        bot.delete_message(update.effective_message.chat_id,
                           update.message.message_id)
예제 #18
0
def check_status(update, context):
    # Telegram Variables
    bot = context.bot
    chat = chat_object(update)
    user = user_object(update)
    get_superban_user_id = update.effective_user.id
    user_photo = user.get_profile_photos(user.id)

    #Get Group via Database
    get_group = GroupRepository().getById(chat.id)
    #Get User via Database
    user_db = UserRepository().getById(user.id)
    #Get User via Database in Many to Many Association
    get_user = UserRepository().getUserByGroup([user.id, chat.id])
    #Get User in Superban Table
    get_superban = SuperbanRepository().getById(get_superban_user_id)
    #Get User Warn
    warn_count = get_user[
        'warn_count'] if get_user is not None else DEFAULT_COUNT_WARN
    #Get Max Warn in group
    max_warn = get_group[
        'max_warn'] if get_group is not None else DEFAULT_MAX_WARN

    if get_group:
        user_set_photo = get_group['set_user_profile_picture']
        type_no_username = get_group['type_no_username']
    else:
        user_set_photo = 0
    #Check if the user has a username if he does not have a username I perform a temporary kick and check that the user is not a service account
    if update.effective_user.id == SERVICE_ACCOUNT:
        print("Service Account")
    elif user.username is None or user.username == "":
        if type_no_username == 1:
            kick_user(update, context)
            msg = "#Automatic Handler\n<code>{}</code> set an username! You were kicked for safety!"
            message(update, context, msg.format(user.id))
        elif type_no_username == 2:
            msg = "#Automatic Handler\n<code>{}</code> set an username!"
            message(update, context, msg.format(user.id))
        elif type_no_username == 3:
            mute_user_by_id(update, context, user.id, True)
            msg = "#Automatic Handler\n<code>{}</code> set an username! You were Muted for safety!"
            message(update, context, msg.format(user.id))
        elif type_no_username == 4:
            ban_user(update, context)
            msg = "#Automatic Handler\n<code>{}</code> was banned because they didn't have an username"
            message(update, context, msg.format(user.id))
        elif type_no_username == 5:
            kick_user(update, context)
        else:
            print("No action even if you don't have a username")
    else:
        #Check if the user exists on the database if it exists makes an update of his username and his latest update if not exist insert it
        if user_db:
            #Get the Current Time
            current_time = datetime.datetime.utcnow().isoformat()
            username = "******" + user.username
            data = [(username, current_time, user.id)]
            UserRepository().update(data)
            data_mtm = [(user.id, chat.id, DEFAULT_COUNT_WARN)]
            UserRepository().add_into_mtm(data_mtm)
        else:
            #Get the Current Time
            current_time = datetime.datetime.utcnow().isoformat()
            username = "******" + user.username
            data = [(user.id, username, current_time, current_time)]
            UserRepository().add(data)
            data_mtm = [(user.id, chat.id, DEFAULT_COUNT_WARN)]
            UserRepository().add_into_mtm(data_mtm)
    #Check if the user has a profile photo
    if user_photo.total_count == 0 and user_set_photo == 1:
        kick_user(update, context)
        msg = "#Automatic Handler\n<code>{}</code> set a profile picture! You were kicked for safety!"
        message(update, context, msg.format(user.id))
    #Check if the user has been blacklisted
    if get_superban:
        superban_reason = get_superban['motivation_text']
        msg = '#Automatic Handler\nI got super banned <a href="tg://user?id={}">{}</a> <code>[{}]</code>\nFor the following Reason: {}'.format(
            user.id, user.first_name, user.id, superban_reason)
        message(update, context, msg)
        delete_message(update, context)
        ban_user(update, context)
    #Check if the user has reached the maximum number of warns and ban him
    if warn_count == max_warn:
        ban_user(update, context)
        msg = "#Automatic Handler\n<code>{}</code> has reached the maximum number of warns"
        message(update, context, msg.format(user.id))

    if flood_manager.check_flood_wait(
            update) == 1 and get_group['set_antiflood'] == 1:
        bot.delete_message(update.effective_message.chat_id,
                           update.message.message_id)
        kick_user(update, context)
        msg = "#Automatic Handler\n<code>{}</code> has been kicked for flood".format(
            user.id)
        message(update, context, msg.format(user.id))