Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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'])
Пример #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)
Пример #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')
Пример #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, "Эта команда только для моего хозяина")
Пример #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)
Пример #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)
Пример #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 — "
                         "номером месяца")
Пример #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, "Эта команда только для моего хозяина")
Пример #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)
Пример #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 файла")
Пример #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 — "
                         "номером дня")
Пример #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, "Надо ответить на сообщение с актом преступления, чтобы переслать контекст\
                          в хранилище")
Пример #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)
Пример #28
0
def counter_handler(message):
    """Подсчитывает сообщения"""
    if config_func.in_mf(message, command_type=None, loud=False, or_private=False):
        reactions.trigger(message)
Пример #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)
Пример #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)