Exemplo n.º 1
0
def welcome_user(update, context, member):
    # Check that the welcome exists on the database if there is no Default Welcome
    chat = update.effective_message.chat_id

    group = GroupRepository().getById(chat)
    if group is not None:
        parsed_message = group['welcome_text'].replace(
            '{first_name}', update.message.from_user.first_name).replace(
                '{chat}',
                update.message.chat.title).replace('{username}',
                                                   "@" + member.username)
        format_message = "{}".format(parsed_message)
        buttons = GroupRepository().getById(chat)
        try:
            welcome_buttons = buttons['welcome_buttons']
            format_json = json.loads(welcome_buttons)
            arr_buttons = []
            for key, value in format_json.items():
                arr_buttons.append(InlineKeyboardButton(text=key, url=value))
            menu = build_menu(arr_buttons, 2)
            update.message.reply_text(format_message,
                                      reply_markup=InlineKeyboardMarkup(menu),
                                      parse_mode='HTML')
        except ValueError:
            reply_message(update, context, format_message)
    else:
        chat_title = update.effective_chat.title
        default_welcome = Config.DEFAULT_WELCOME.format(
            "@" + member.username, chat_title)
        reply_message(update, context, default_welcome)
Exemplo n.º 2
0
def save_group(update):
    chat = update.effective_message.chat_id
    group = GroupRepository().getById(chat)
    if group:
        print('update group')
        #data = [(chat,chat)]
        #GroupRepository().update(data)
    else:
        default_welcome = Config.DEFAULT_WELCOME.format("{username}", "{chat}")
        default_buttons = ""
        default_rules = Config.DEFAULT_RULES
        default_lang = Config.DEFAULT_LANGUAGE
        default_community = 0
        default_set_welcome = 1
        default_max_warn = 3
        default_global_silence = 0
        default_exe_filter = 0
        default_block_user = 0
        default_arabic_filter = 1
        default_cirillic_filter = 1
        default_chinese_filter = 1
        default_user_profile_photo = 0
        data = [(chat, default_welcome, default_buttons, default_rules,
                 default_community, default_lang, default_set_welcome,
                 default_max_warn, default_global_silence, default_exe_filter,
                 default_block_user, default_arabic_filter,
                 default_cirillic_filter, default_chinese_filter,
                 default_user_profile_photo)]
        GroupRepository().add(data)
Exemplo n.º 3
0
def update_db_settings(update, record, options):
    chat = update.effective_message.chat_id
    if options == True:
        data = [(0, chat)]
        upd = GroupRepository().update_group_settings(record, data)
    else:
        data = [(1, chat)]
        upd = GroupRepository().update_group_settings(record, data)
    return upd
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
0
def update_shield(update, context):
    bot = context.bot
    query = update.callback_query
    if query.data == 'removeShield':
        chat = update.effective_message.chat_id
        chat_title = update.effective_message.chat.title
        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 = [(1, 0, chat)]
        GroupRepository().set_block_entry(data)
        update_db_settings(update, record_arabic, True)
        update_db_settings(update, record_chinese, True)
        update_db_settings(update, record_cirillic, True)
        update_db_settings(update, record_no_user_photo, True)
        update_db_settings(update, record_silence, True)
        update_db_settings(update, record_block_channel, True)
        update_db_settings(update, record_zoophile, True)
        bot.set_chat_permissions(update.effective_chat.id, PERM_TRUE)
        msg = '✅ Shield removed!'
        query.edit_message_text(msg, parse_mode='HTML')
        logs_text = '🛡Shield Deactivated in {} <code>[{}]</code>'.format(
            chat_title, chat)
        telegram_loggers(update, context, logs_text)
Exemplo n.º 8
0
def keyboard_settings(update,context,editkeyboard = False):
    bot = context.bot
    chat = update.message.chat_id
    chat_title = update.message.chat.title
    group = GroupRepository().getById(chat)
    list_buttons = []
    list_buttons.append(InlineKeyboardButton('%s Welcome 👋🏻' % ('✅' if group['set_welcome'] == 1 else '❌'), callback_data='setWelcome'))
    list_buttons.append(InlineKeyboardButton('%s Silence 🤫' % ('✅' if group['set_silence'] == 1 else '❌'), callback_data='setSilence'))
    list_buttons.append(InlineKeyboardButton('%s Deny All Entry 🚷' % ('✅' if group['block_new_member'] == 1 else '❌'), callback_data='setBlockEntry'))
    list_buttons.append(InlineKeyboardButton('%s AntiFlood 🚫' % ('✅' if group['set_antiflood'] == 1 else '❌'), callback_data='setAntiflood'))
    list_buttons.append(InlineKeyboardButton('%s No User Photo Entry ⛔️' % ('✅' if group['set_user_profile_picture'] == 1 else '❌'), callback_data='userPhoto'))
    list_buttons.append(InlineKeyboardButton('%s No Arabic Entry ⛔️' % ('✅' if group['set_arabic_filter'] == 1 else '❌'), callback_data='arabic'))
    list_buttons.append(InlineKeyboardButton('%s No Russian Entry ⛔️' % ('✅' if group['set_cirillic_filter'] == 1 else '❌'), callback_data='cirillic'))
    list_buttons.append(InlineKeyboardButton('%s No Chinese Entry ⛔️' % ('✅' if group['set_chinese_filter'] == 1 else '❌'), callback_data='chinese'))
    list_buttons.append(InlineKeyboardButton('%s No ZooPhile Entry ⛔️' % ('✅' if group['zoophile_filter'] == 1 else '❌'), callback_data='zoophile'))
    list_buttons.append(InlineKeyboardButton('%s Block Vocal ⛔️' % ('✅' if group['set_no_vocal'] == 1 else '❌'), callback_data='novocal'))
    list_buttons.append(InlineKeyboardButton('%s Block Channel 📢' % ('✅' if group['sender_chat_block'] == 1 else '❌'), callback_data='channelblock'))
    list_buttons.append(InlineKeyboardButton('%s Block Spoiler 🚫' % ('✅' if group['spoiler_block'] == 1 else '❌'), callback_data='spoilerblock'))
    list_buttons.append(InlineKeyboardButton('Languages', callback_data='lang'))
    list_buttons.append(InlineKeyboardButton('Commands', url='https://github.com/Squirrel-Network/nebula8/wiki/Command-List'))
    list_buttons.append(InlineKeyboardButton('Dashboard', url='https://nebula.squirrel-network.online'))
    list_buttons.append(InlineKeyboardButton("Close", callback_data='close'))
    menu = build_menu(list_buttons,2)
    if editkeyboard == False:
        keyboard_menu = bot.send_message(chat,"⚙️ Bot settings\n\n📜 Group Name: <i>{}</i>\n🏷 ChatId: <code>{}</code>".format(chat_title,chat),reply_markup=InlineKeyboardMarkup(menu),parse_mode='HTML')
    if editkeyboard == True:
        keyboard_menu = bot.edit_message_reply_markup(chat,update.message.message_id,reply_markup=InlineKeyboardMarkup(menu))
    return keyboard_menu
Exemplo n.º 9
0
def keyboard_filters(update, context, editkeyboard=False):
    bot = context.bot
    chat = update.message.chat_id
    group = GroupRepository().getById(chat)
    list_buttons = []
    list_buttons.append(
        InlineKeyboardButton('Exe Filters %s' %
                             ('✅' if group['exe_filter'] == 1 else '❌'),
                             callback_data='exe_filters'))
    list_buttons.append(
        InlineKeyboardButton('Zip Filters', callback_data='zip_filters'))
    list_buttons.append(
        InlineKeyboardButton('TarGZ Filters', callback_data='targz_filters'))
    list_buttons.append(InlineKeyboardButton("Close", callback_data='close'))
    menu = build_menu(list_buttons, 2)
    if editkeyboard == False:
        keyboard_menu = bot.send_message(
            chat,
            "Filters Settings",
            reply_markup=InlineKeyboardMarkup(menu),
            parse_mode='HTML')
    if editkeyboard == True:
        keyboard_menu = bot.edit_message_reply_markup(
            chat,
            update.message.message_id,
            reply_markup=InlineKeyboardMarkup(menu))
    return keyboard_menu
Exemplo n.º 10
0
def update_warn(update,context):
    query = update.callback_query
    user_id = query.message.reply_to_message.from_user.id
    chat_id = query.message.reply_to_message.chat_id
    get_user = UserRepository().getUserByGroup([user_id,chat_id])
    get_group = GroupRepository().getById(chat_id)
    max_warn = get_group['max_warn']
    warn_count = get_user['warn_count'] if get_user is not None else 0
    if query.data == 'upWarn':
        if warn_count != max_warn:
            data_warn = [(user_id,chat_id)]
            UserRepository().updateWarn(data_warn)
            msg = 'You Upwarned: <a href="tg://user?id={}">{}</a>'.format(user_id,user_id)
            query.edit_message_text(msg, parse_mode='HTML')
        else:
            ban_user_by_id(update,context,user_id)
            msg = "The user has been banned because it has reached the maximum number of warns"
            query.edit_message_text(msg, parse_mode='HTML')
    if query.data == 'downWarn':
        if warn_count != 0:
            data_warn = [(user_id,chat_id)]
            UserRepository().downWarn(data_warn)
            msg = 'You Downwarned: <a href="tg://user?id={}">{}</a>'.format(user_id,user_id)
            query.edit_message_text(msg, parse_mode='HTML')
        else:
            msg = "The user cannot be downwarned anymore!"
            query.edit_message_text(msg, parse_mode='HTML')
    if query.data == 'removeWarn':
        data_warn = [(user_id,chat_id)]
        UserRepository().removeWarn(data_warn)
        msg = 'You have removed the Warns from user: <a href="tg://user?id={}">{}</a>'.format(user_id,user_id)
        query.edit_message_text(msg, parse_mode='HTML')
Exemplo n.º 11
0
def save_group(update):
    chat = update.effective_message.chat_id
    chat_title = update.effective_chat.title
    record = GroupRepository.SET_GROUP_NAME
    group = GroupRepository().getById(chat)
    if group:
        data = [(chat_title, chat)]
        GroupRepository().update_group_settings(record, data)
    else:
        dictionary = {
            "id_group": chat,
            "group_name": chat_title,
            "welcome_text":
            Config.DEFAULT_WELCOME.format("{mention}", "{chat}"),
            "welcome_buttons":
            '{"buttons": [{"id": 0,"title": "Bot Logs","url": "https://t.me/nebulalogs"}]}',
            "rules_text": Config.DEFAULT_RULES,
            "community": 0,
            "languages": Config.DEFAULT_LANGUAGE,
            "set_welcome": 1,
            "max_warn": 3,
            "set_silence": 0,
            "exe_filter": 0,
            "block_new_member": 0,
            "set_arabic_filter": 0,
            "set_cirillic_filter": 0,
            "set_chinese_filter": 0,
            "set_user_profile_picture": 0,
            "gif_filter": 0,
            "set_cas_ban": 1,
            "type_no_username": 1,
            "log_channel": Config.DEFAULT_LOG_CHANNEL,
            "group_photo": 'https://naos.hersel.it/group_photo/default.jpg',
            "total_users": 0,
            "zip_filter": 0,
            "targz_filter": 0,
            "jpg_filter": 0,
            "docx_filter": 0,
            "apk_filter": 0,
            "zoophile_filter": 1,
            "sender_chat_block": 1,
            "spoiler_block": 0,
            "set_no_vocal": 0,
            "set_antiflood": 1,
            "ban_message": '{mention} has been <b>banned</b> from: {chat}'
        }
        GroupRepository().add_with_dict(dictionary)
Exemplo n.º 12
0
def update_rules(update, context):
    query = update.callback_query
    if query.data == 'openRules':
        languages(update, context)
        chat = update.effective_message.chat_id
        row = GroupRepository().getById([chat])
        query.edit_message_text(languages.rules.format(row['rules_text']),
                                parse_mode='HTML')
Exemplo n.º 13
0
def check_group_badwords(update):
    chat_id = update.effective_chat.id
    bad_word = update.effective_message.text or update.effective_message.caption
    if bad_word is not None:
        row = GroupRepository().get_group_badwords([bad_word, chat_id])
        if row:
            return True
        else:
            return False
Exemplo n.º 14
0
def language_en(update, context):
    chat = update.effective_message.chat_id
    msg = "You have selected the English language for your group"
    query = update.callback_query
    query.answer()
    lang = "EN"
    data = [(lang, chat)]
    GroupRepository().update_group_settings(record, data)
    query.edit_message_text(msg, parse_mode='HTML')
Exemplo n.º 15
0
def init(update, context):
    languages(update, context)
    chat = update.effective_message.chat_id
    rows = GroupRepository().getById([chat])
    for row in rows:
        message(
            update, context,
            languages.group_info.format(row['id_group'], row['welcome_text'],
                                        row['rules_text'], row['languages']))
Exemplo n.º 16
0
def language_it(update, context):
    chat = update.effective_message.chat_id
    msg = "Hai selezionato la lingua italiana per il tuo gruppo"
    query = update.callback_query
    query.answer()
    lang = "IT"
    data = [(lang, chat)]
    GroupRepository().update_group_settings(record, data)
    query.edit_message_text(msg, parse_mode='HTML')
Exemplo n.º 17
0
def _remove_button(group_id, btn_id):
    """
     group_id, int indicating the id of the group
     btn_id, json button id to remove
    """
    # select
    group_record = GroupRepository().getById(group_id)
    welcome_btns = group_record['welcome_buttons']
    welcome_btns = json.loads(welcome_btns)['buttons']

    new_welcome_btns = [
        btn for btn in welcome_btns if btn['id'] != int(btn_id)
    ]

    # insert
    welcome_btns_text = json.dumps({"buttons": new_welcome_btns})
    GroupRepository().updateWelcomeButtonsByGroupId(group_id,
                                                    welcome_btns_text)
Exemplo n.º 18
0
def set_ban_message(update, context):
    languages(update, context)
    record = GroupRepository.BAN_MESSAGE
    chat = update.effective_chat.id
    msg = update.message.text[7:]
    reply = update.message.reply_to_message
    if reply:
        ban_text = str(reply.text).lower()
        data = [(ban_text, chat)]
        GroupRepository().update_group_settings(record, data)
        message(update, context, text="Testo Ban impostato!")
    else:
        if msg != "":
            data = [(msg, chat)]
            GroupRepository().update_group_settings(record, data)
            message(update, context, "Hai Impostato il Messaggio Di Ban!")
        else:
            message(update, context, "Il testo del ban non può essere vuoto!")
Exemplo n.º 19
0
def init(update, context):
    languages(update, context)
    record = GroupRepository.SET_WELCOME_TEXT
    chat = update.effective_chat.id
    msg = update.message.text[8:].strip()
    reply = update.message.reply_to_message
    if reply:
        welcome_text = str(reply.text).lower()
        data = [(welcome_text, chat)]
        GroupRepository().update_group_settings(record, data)
        message(update, context, text="Welcome impostato!")
    else:
        if msg != "":
            data = [(msg, chat)]
            GroupRepository().update_group_settings(record, data)
            message(update, context, languages.set_welcome_help)
        else:
            message(update, context, languages.set_welcome_main)
Exemplo n.º 20
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)
Exemplo n.º 21
0
def init(update, context):
    languages(update, context)
    chat = update.effective_message.chat_id
    chat_title = update.effective_chat.title
    record = GroupRepository.SET_GROUP_NAME
    row = GroupRepository().getById([chat])
    if row:
        data = [(chat_title, chat)]
        GroupRepository().update_group_settings(record, data)
        counter = GroupRepository().getUpdatesByChatMonth(chat)
        img = row['group_photo']
        caption = languages.group_info.format(
            row['group_name'], row['id_group'], row['welcome_text'],
            row['rules_text'], row['languages'], row['max_warn'],
            row['total_users'], counter['counter'])
        messagePhoto(update, context, img, caption)
    else:
        save_group(update)
Exemplo n.º 22
0
def init(update, context):
    apk = 'application/vnd.android.package-archive'
    doc = 'application/msword'
    docx = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
    exe = 'application/x-ms-dos-executable'
    gif = 'video/mp4'
    jpg = 'image/jpeg'
    mp3 = 'audio/mpeg'
    pdf = 'application/pdf'
    py = 'text/x-python'
    svg = 'image/svg+xml'
    txt = 'text/plain'
    targz = 'application/x-compressed-tar'
    wav = 'audio/x-wav'
    xml = 'application/xml'
    filezip = 'application/zip'

    msg = update.effective_message
    chat = update.effective_message.chat_id
    group = GroupRepository().getById(chat)

    if msg.document is not None:
        if msg.document.mime_type == apk:
            print("NO APK ALLOWED")
        if msg.document.mime_type == doc or msg.document.mime_type == docx:
            print("NO DOC/DOCX ALLOWED")
        if msg.document.mime_type == exe and group['exe_filter'] == 1:
            delete_message(update, context)
            message(update, context,
                    "#Automatic Filter Handler: <b>No EXE Allowed!</b>")
        if msg.document.mime_type == gif:
            print("NO GIF ALLOWED")
        if msg.document.mime_type == jpg:
            print("NO JPG ALLOWED")
        if msg.document.mime_type == mp3:
            print("NO MP3 ALLOWED")
        if msg.document.mime_type == pdf:
            print("NO PDF ALLOWED")
        if msg.document.mime_type == py:
            print("NO PY ALLOWED")
        if msg.document.mime_type == svg:
            print("NO SVG ALLOWED")
        if msg.document.mime_type == txt:
            print("NO TXT ALLOWED")
        if msg.document.mime_type == targz:
            delete_message(update, context)
            message(update, context,
                    "#Automatic Filter Handler: <b>No TARGZ Allowed!</b>")
        if msg.document.mime_type == wav:
            print("NO WAV ALLOWED")
        if msg.document.mime_type == xml:
            print("NO XML ALLOWED")
        if msg.document.mime_type == filezip:
            delete_message(update, context)
            message(update, context,
                    "#Automatic Filter Handler: <b>No ZIP Allowed!</b>")
Exemplo n.º 23
0
def init(update, context):
    languages(update,context)
    chat = update.effective_chat.id
    msg = update.message.text[8:].strip()
    if msg != "":
        data = [(msg, chat)]
        GroupRepository().update_group_welcome(data)
        message(update, context, languages.set_welcome_help)
    else:
        message(update, context, languages.set_welcome_main)
Exemplo n.º 24
0
def telegram_loggers(update, context, msg=""):
    chat = update.effective_message.chat_id
    row = GroupRepository().getById([chat])
    id_channel = Config.DEFAULT_LOG_CHANNEL
    if row:
        get_log_channel = row['log_channel']
        send = messageWithId(update, context, get_log_channel, msg)
    else:
        send = messageWithId(update, context, id_channel, msg)
    return send
Exemplo n.º 25
0
def update_set_warn(update, context):
    query = update.callback_query
    if query.data.startswith("w"):
        chat_id = query.message.chat_id
        warn_limit = query.data[1:]
        record = GroupRepository.SET_MAX_WARN
        data = [(warn_limit,chat_id)]
        GroupRepository().update_group_settings(record, data)
        text = "You have changed the maximum number\nof warns in this group to <code>{}</code>".format(warn_limit)
        query.edit_message_text(text, parse_mode='HTML')
Exemplo n.º 26
0
def init(update, context):
    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>"
        )
Exemplo n.º 27
0
def callback_all_chat(context):
    rows = GroupRepository().getAll()
    for a in rows:
        try:
            chat_id = a['id_group']
            x = chat_status_object_by_id(context,chat_id)
            time.sleep(2)
            print(x)
        except Unauthorized:
            print("NOT FOUND")
Exemplo n.º 28
0
def keyboard_settings(update, context, editkeyboard=False):
    bot = context.bot
    chat = update.message.chat_id
    group = GroupRepository().getById(chat)
    list_buttons = []
    list_buttons.append(
        InlineKeyboardButton('Welcome %s' %
                             ('✅' if group['set_welcome'] == 1 else '❌'),
                             callback_data='setWelcome'))
    list_buttons.append(
        InlineKeyboardButton('Silence %s' %
                             ('✅' if group['set_silence'] == 1 else '❌'),
                             callback_data='setSilence'))
    list_buttons.append(
        InlineKeyboardButton('Deny All Entry %s' %
                             ('✅' if group['block_new_member'] == 1 else '❌'),
                             callback_data='setBlockEntry'))
    list_buttons.append(
        InlineKeyboardButton(
            'No User Photo Entry %s' %
            ('✅' if group['set_user_profile_picture'] == 1 else '❌'),
            callback_data='userPhoto'))
    list_buttons.append(
        InlineKeyboardButton('No Arabic Entry %s' %
                             ('✅' if group['set_arabic_filter'] == 1 else '❌'),
                             callback_data='arabic'))
    list_buttons.append(
        InlineKeyboardButton(
            'No Russian Entry %s' %
            ('✅' if group['set_cirillic_filter'] == 1 else '❌'),
            callback_data='cirillic'))
    list_buttons.append(
        InlineKeyboardButton(
            'No Chinese Entry %s' %
            ('✅' if group['set_chinese_filter'] == 1 else '❌'),
            callback_data='chinese'))
    list_buttons.append(InlineKeyboardButton('Languages',
                                             callback_data='lang'))
    list_buttons.append(
        InlineKeyboardButton('Chat Filters', callback_data='Filters'))
    list_buttons.append(InlineKeyboardButton("Close", callback_data='close'))
    menu = build_menu(list_buttons, 2)
    if editkeyboard == False:
        keyboard_menu = bot.send_message(
            chat,
            "Group Settings",
            reply_markup=InlineKeyboardMarkup(menu),
            parse_mode='HTML')
    if editkeyboard == True:
        keyboard_menu = bot.edit_message_reply_markup(
            chat,
            update.message.message_id,
            reply_markup=InlineKeyboardMarkup(menu))
    return keyboard_menu
Exemplo n.º 29
0
def init(update, context):
    record = GroupRepository.SET_RULES_TEXT
    chat = update.effective_chat.id
    msg = update.message.text[9:].strip()
    languages(update, context)
    if msg != "":
        data = [(msg, chat)]
        GroupRepository().update_group_settings(record, data)
        message(update, context, languages.rules_msg)
    else:
        message(update, context, languages.rules_error_msg)
Exemplo n.º 30
0
def update_set_tpnu(update, context):
    query = update.callback_query
    if query.data.startswith("tpnu"):
        chat_id = query.message.chat_id
        tpnu_set = query.data[4:]
        record = GroupRepository.SET_TPNU
        data = [(tpnu_set, chat_id)]
        GroupRepository().update_group_settings(record, data)
        text = "You have set the filter to <code>{}</code>\nLegend:\n<code>1 == Kick\n2 == Message\n3 == Mute\n4 == Ban\n5 == Silent Kick\n6 == No Action</code>".format(
            tpnu_set)
        query.edit_message_text(text, parse_mode='HTML')