Exemplo n.º 1
0
def money_fund_handler(message):
    """Transfer money to the chat fund"""
    if config_func.in_mf(message, 'financial_commands', or_private=False):
        analyzer = config_func.Analyzer(message)
        parameters_dictionary = analyzer.parameters_dictionary
        if parameters_dictionary:
            standard_commands.money_fund(message, parameters_dictionary)
Exemplo n.º 2
0
def send_me_handler(message):
    """Присылает человеку его запись в БД"""
    if config_func.in_mf(message, command_type=None, or_private=False):
        person = config_func.Analyzer(message,
                                      value_necessary=False).return_target_person(to_self=True)
        if person:
            standard_commands.send_me(message, person)
Exemplo n.º 3
0
def upload_stuff_to_storage_handler(message):
    """ Add stuff to a media storage """
    analyzer = config_func.Analyzer(message, value_necessary=False)
    storage_name = analyzer.parameters_dictionary['comment']
    if config_func.in_mf(message, command_type=None):
        if config_func.check_access_to_a_storage(message, storage_name, is_write_mode=True):
            boss_commands.add_stuff_to_storage(message, storage_name)
Exemplo n.º 4
0
def check_storage_size_handler(message):
    """ Checks how many moderators and how much media there is in a storage """
    analyzer = config_func.Analyzer(message, value_necessary=False)
    storage_name = analyzer.parameters_dictionary['comment']
    if config_func.in_mf(message, 'standard_commands') and config_func.check_access_to_a_storage(
            message, storage_name, False, to_check_vulgarity=False):
        standard_commands.check_storage_size(message, storage_name)
Exemplo n.º 5
0
def kick_handler(message):
    """ Kicks member """
    if config_func.in_mf(message, 'boss_commands', or_private=False) and config_func.is_suitable(
            message, message.from_user, 'boss'):
        person = config_func.Analyzer(message, value_necessary=False).return_target_person()
        if person and config_func.rank_superiority(message, person):
            boss_commands.ban(message, person, unban_then=True)
Exemplo n.º 6
0
def admins_handler(message):
    """Ping admins"""
    if config_func.in_mf(message, command_type=None) and config_func.is_suitable(message,
                                                                                 message.from_user,
                                                                                 "standard") \
            and config_func.cooldown(message, 'admins', 300):
        standard_commands.admins(message)
Exemplo n.º 7
0
def rank_changer_handler(message):
    """Changes person's rank"""
    if config_func.in_mf(message, command_type=None, or_private=False):
        if config_func.is_suitable(message, message.from_user, 'uber'):
            person = config_func.Analyzer(message, value_necessary=False).return_target_person(to_self=True)
            if person:
                if person.id == message.from_user.id or config_func.rank_superiority(message, person):
                    boss_commands.rank_changer(message, person)
Exemplo n.º 8
0
def unwarn_handler(message):
    """Снимает с участника предупреждение"""
    if config_func.in_mf(message, 'boss_commands', or_private=False) and config_func.is_suitable(
            message, message.from_user, 'boss'):
        analyzer = config_func.Analyzer(message, default_value=1, value_positive=True)
        person = analyzer.return_target_person()
        if person:
            boss_commands.unwarn(message, person, analyzer.parameters_dictionary)
Exemplo n.º 9
0
def warns_top_handler(message):
    """ Show all warns """
    if config_func.in_mf(message, command_type=None, or_private=False):
        language = config_func.get_one_language(message)
        if language:
            args = message, language, '{index}. {p_link} — {warns} ⛔️\n'
            kwargs = {'start': 'Количество варнов:\n\n', 'sort_key': lambda x: x['warns']}
            standard_commands.send_some_top(*args, **kwargs)
Exemplo n.º 10
0
def set_limit_handler(message):
    """Sets the limit for entering the chat"""
    if config_func.in_mf(message, command_type=None, or_private=False) and config_func.is_suitable(
            message, message.from_user, "chat_changer"):
        analyzer = config_func.Analyzer(message)
        parameters_dictionary = analyzer.parameters_dictionary
        if parameters_dictionary:
            boss_commands.set_limit(message, parameters_dictionary)
Exemplo n.º 11
0
def money_give_handler(message):
    """Обмен денег между пользователями"""
    if config_func.in_mf(message, 'financial_commands', or_private=False):
        analyzer = config_func.Analyzer(message)
        person = analyzer.return_target_person()
        parameters_dictionary = analyzer.parameters_dictionary
        if person and parameters_dictionary:
            standard_commands.money_give(message, person, parameters_dictionary)
Exemplo n.º 12
0
def mute_handler(message):
    """ Mutes member """
    if config_func.in_mf(message, "boss_commands", or_private=False) and config_func.is_suitable(
            message, message.from_user, 'boss'):
        analyzer = config_func.Analyzer(message, default_value=1, value_positive=True)
        person = analyzer.return_target_person()
        parameters_dictionary = analyzer.parameters_dictionary
        if person and config_func.rank_superiority(message, person) and parameters_dictionary:
            boss_commands.mute(message, person, parameters_dictionary)
Exemplo n.º 13
0
def money_pay_handler(message):
    """ Give money from the treasury to the member """
    if config_func.in_mf(message, 'financial_commands', or_private=False) \
            and config_func.is_suitable(message, message.from_user, 'boss'):
        analyzer = config_func.Analyzer(message)
        person = analyzer.return_target_person(to_self=True)
        parameters_dictionary = analyzer.parameters_dictionary
        if person and parameters_dictionary:
            boss_commands.money_pay(message, person, parameters_dictionary)
Exemplo n.º 14
0
def messages_change_handler(message):
    """Меняет запись в БД о количестве сообщений чела"""
    if config_func.in_mf(message, 'boss_commands', or_private=False) and config_func.is_suitable(
            message, message.from_user, "boss"):
        analyzer = config_func.Analyzer(message, value_positive=True)
        person = analyzer.return_target_person(to_self=True)
        parameters_dictionary = analyzer.parameters_dictionary
        if person and parameters_dictionary:
            boss_commands.message_change(message, person, parameters_dictionary)
Exemplo n.º 15
0
def birthday_handler(message):
    """Show the nearest birthdays"""
    if config_func.in_mf(message, command_type=None):
        language = config_func.get_one_language(message)
        if language:
            standard_commands.send_some_top(
                message,
                language,
                '{index}. {p_link} — {day} {month}\n',
                sort_key=lambda x: -100 * x['month_birthday'] - x['day_birthday'])
Exemplo n.º 16
0
def messages_top_handler(message):
    """Messages top"""
    if config_func.in_mf(message, command_type=None, or_private=False):
        language = config_func.get_one_language(message)
        if language:
            args = message, language, '{index}. {p_link} — {messages} сообщ.\n'
            kwargs = {'sort_key': lambda x: x['messages']}
            if config_func.is_suitable(message, message.from_user, 'boss', loud=False):
                standard_commands.send_some_top(*args, **kwargs)
            else:
                standard_commands.send_short_top(*args, **kwargs)
Exemplo n.º 17
0
def all_members_handler(message):
    """Присылает человеку все записи в БД"""
    if config_func.in_mf(message, command_type=None, or_private=False):
        language = config_func.get_one_language(message)
        if language:
            if config_func.is_suitable(message, message.from_user, 'boss', loud=False):
                standard_commands.send_some_top(message, language,
                                                '{index}. <code>{id}</code> {p_link}\n')
            else:
                standard_commands.send_some_top(message, language,
                                                '{index}. <code>{id}</code> {nickname}\n')
Exemplo n.º 18
0
def remove_moderator_from_storage_handler(message):
    """ Removes a moderator from a storage """
    analyzer = config_func.Analyzer(message, value_necessary=False)
    person = analyzer.return_target_person(to_self=True)
    storage_name = analyzer.parameters_dictionary['comment']
    if config_func.in_mf(message, command_type=None) and person and \
            config_func.check_access_to_a_storage(message, storage_name, False):
        if message.from_user.id == config_var.CREATOR_ID:
            boss_commands.remove_moderator_from_storage(message, storage_name, person.id)
        else:
            output.reply(message, "Эта команда только для моего хозяина")
Exemplo n.º 19
0
def money_top_handler(message):
    """Топ ЯМ"""
    if config_func.in_mf(message, 'financial_commands', or_private=False):
        language = config_func.get_one_language(message)
        if language:
            args = message, language, '{index}. {p_link} — {money} {m_emo}\n'
            kwargs = {'start': 'Бюджет: {bot_money} {m_emo}\n\n', 'sort_key': lambda x: x['money']}
            if config_func.is_suitable(message, message.from_user, 'boss', loud=False):
                standard_commands.send_some_top(*args, **kwargs)
            else:
                standard_commands.send_short_top(*args, **kwargs)
Exemplo n.º 20
0
def send_stuff_from_storage_handler(message):
    """Send random media from the storage"""
    analyzer = config_func.Analyzer(message, value_necessary=False)
    storage_name = analyzer.parameters_dictionary['comment']
    if config_func.in_mf(message, 'standard_commands') and config_func.check_access_to_a_storage(
            message, storage_name, False) and config_func.cooldown(message, storage_name,
                                                                   timeout=300):
        if "value" in analyzer.parameters_dictionary:
            stuff_number = analyzer.parameters_dictionary["value"]
            standard_commands.send_numbered_stuff_from_storage(message, storage_name, stuff_number)
        else:
            standard_commands.send_random_stuff_from_storage(message, storage_name)
Exemplo n.º 21
0
def month_set_handler(message):
    """Set month of person's birthday"""
    if config_func.in_mf(message, command_type=None):
        month = message.text.split()[-1]
        if month.isdecimal():
            month = int(month)
            if month and 1 <= month <= 12:
                standard_commands.month_set(message, month)
        else:
            output.reply(
                message, "Последнее слово должно быть положительным числом от 1 до 12 — "
                         "номером месяца")
Exemplo n.º 22
0
def create_new_vulgar_storage_handler(message):
    """ Creates new vulgar media storage """
    analyzer = config_func.Analyzer(message, value_necessary=False)
    storage_name = analyzer.parameters_dictionary['comment']
    if config_func.in_mf(message, command_type=None):
        if message.from_user.id == config_var.CREATOR_ID:
            if storage_name:
                boss_commands.create_new_storage(message, storage_name, True)
            else:
                output.reply(message, "Не хватает названия")
        else:
            output.reply(message, "Эта команда только для моего хозяина")
Exemplo n.º 23
0
def shuffle_handler(message):
    """ Shuffle a list """
    if config_func.in_mf(message, 'standard_commands'):
        analyzer = config_func.Analyzer(message, value_necessary=False)
        elements = analyzer.parameters_dictionary['comment'].split()
        if not elements:
            output.reply(message, 'Пожалуйста, напишите список, '
                                  'а элементы списка разделите пробелом')
        shuffle(elements)
        if 'value' in analyzer.parameters_dictionary:
            elements = elements[:analyzer.parameters_dictionary['value']]
        out = '\n'.join(f'{i + 1}. {j}' for i, j in enumerate(elements))
        output.reply(message, out)
Exemplo n.º 24
0
def remove_stuff_from_storage_handler(message):
    """Removes some media from media storage"""
    analyzer = config_func.Analyzer(message, value_necessary=False)
    comment = analyzer.parameters_dictionary['comment']
    if config_func.in_mf(message, command_type=None):
        list_of_words = comment.split()
        if len(list_of_words) >= 2:
            storage_name = list_of_words[0]
            file_id = list_of_words[1]
            if config_func.check_access_to_a_storage(message, storage_name, is_write_mode=True):
                boss_commands.remove_stuff_from_storage(message, storage_name, file_id)
        else:
            output.reply(message, "Нужно название хранилища и ID файла")
Exemplo n.º 25
0
def day_set_handler(message):
    """Set day of person's birthday"""
    if config_func.in_mf(message, command_type=None):
        day = message.text.split()[-1]
        if day.isdecimal():
            day = int(day)
            if day and 1 <= day <= 31:
                language = config_func.get_one_language(message)
                if language:
                    standard_commands.day_set(message, day, language)
        else:
            output.reply(
                message, "Последнее слово должно быть положительным числом от 1 до 31 — "
                         "номером дня")
Exemplo n.º 26
0
def warn_handler(message):
    """Даёт участнику предупреждение"""
    if config_func.in_mf(message, 'boss_commands', or_private=False) and config_func.is_suitable(
            message, message.from_user, 'boss'):
        rep = message.reply_to_message
        if rep:
            analyzer = config_func.Analyzer(message, default_value=1, value_positive=True)
            parameters_dictionary = analyzer.parameters_dictionary
            if analyzer.check_person(rep.from_user, False, False) \
                    and config_func.rank_superiority(message, rep.from_user):
                if parameters_dictionary:
                    boss_commands.warn(message, rep.from_user, parameters_dictionary)
        else:
            output.reply(
                message, "Надо ответить на сообщение с актом преступления, чтобы переслать контекст\
                          в хранилище")
Exemplo n.º 27
0
def language_getter_handler(message):
    """Gets the language of the chat"""
    if config_func.in_mf(message, command_type=None, or_private=True):
        if message.chat.id > 0 or config_func.is_suitable(message, message.from_user, 'boss'):
            boss_commands.language_setter(message)
Exemplo n.º 28
0
def counter_handler(message):
    """Подсчитывает сообщения"""
    if config_func.in_mf(message, command_type=None, loud=False, or_private=False):
        reactions.trigger(message)
Exemplo n.º 29
0
def system_check_handler(message):
    """Show options of the current chat"""
    if config_func.in_mf(message, command_type=None, or_private=False):
        standard_commands.system_check(message)
Exemplo n.º 30
0
def send_meme_handler(message):
    """Присылает мем"""
    if config_func.in_mf(message, 'standard_commands') and config_func.cooldown(message, 'meme'):
        standard_commands.send_meme(message)