Example #1
0
def text_parser(message):
    if message.chat.id in cfg.subscribed_chats:
        cid = message.chat.id
        uid = message.from_user.id
        # лол кек ахахаха детектор
        if utils.getSettings(cid, 'lol_kek') == 1:
            if tp.lol_kek_detector(message.text) is True:  # оптимизация
                if random.random() >= 0.8:
                    bot.send_sticker(cid, random.choice(cfg.sticker_var))
                    print('Sent!')

        # голосование за обед
        if utils.getSettings(cid, 'autodetect_vote') == 1:
            din_elec = tp.dinner_election(message.text, cid)
            # ТОЛЬКО ДЛЯ ТЕСТИРОВАНИЯ!!!
            # if din_elec is not False:

            if din_elec:
                # проверяем что пользователь может голосовать
                vote_today_err = utils.user_vote_check(cid, uid)
                if vote_today_err is None:
                    bot.send_chat_action(cid, 'typing')
                    utils.vote_func(din_elec, bot, message)
                else:
                    bot.reply_to(message, vote_today_err)
Example #2
0
def text_parser(message):
    week_day = datetime.datetime.today().weekday()
    # нужно брать дату из даты сообщения
    hour_msg = time.localtime(message.date).tm_hour
    # текущее время, может пригодиться
    # hour_now = time.localtime().tm_hour
    cid = message.chat.id
    # user_id = message.from_user.id

    if cid in cfg.subscribed_chats:
        # лол кек ахахаха детектор
        if utils.getSettings(
                cid,
                'lol_kek') == 1 and tp.lol_kek_detector(message.text) is True:
            if random.random() >= 0.8:
                bot.send_sticker(cid, random.choice(cfg.sticker_var))
                print('Sent!')

        # голосование за обед
        if utils.getSettings(cid, 'autodetect_vote') == 1:
            din_elec = tp.dinner_election(message.text, cid)
            # ТОЛЬКО ДЛЯ ТЕСТИРОВАНИЯ!!!
            # if din_elec is not False:

            # проверяем что сегодня не выходной и время меньше чем час обеда в этом чате
            if week_day not in (5, 6) and hour_msg < utils.getSettings(
                    cid, 'elec_end_hour') and din_elec:
                bot.send_chat_action(cid, 'typing')
                utils.vote_func(din_elec, bot, message)
Example #3
0
def vote_cmd(message):
    try:
        cid = message.chat.id
        uid = message.from_user.id
        msg = message.text.strip().split()
        # проверка корректности ввода
        if len(msg) == 2 and tp.dinner_election(msg[1], cid,
                                                manual=True) is not False:
            din_elec = int(msg[1])
            # проверяем что сегодня не выходной и время меньше чем час обеда в этом чате
            vote_today_err = utils.user_vote_check(cid, uid)
            if vote_today_err is None:
                bot.send_chat_action(cid, 'typing')
                utils.vote_func(din_elec, bot, message)
            else:
                bot.reply_to(message, vote_today_err)
        else:
            bot.send_message(cid,
                             cfg.err_wrong_cmd.format('vote [+/-]NN'),
                             parse_mode='HTML')
    except Exception as e:
        print('***ERROR: Проблема с командой vote_cmd***')
        print('Exception text: ' + str(e))
Example #4
0
def vote_cmd(message):
    try:
        cid = message.chat.id
        msg = message.text.strip().split()
        # проверка корректности ввода
        if len(msg) == 2 and tp.dinner_election(msg[1], cid,
                                                manual=True) is not False:
            week_day = datetime.datetime.today().weekday()
            hour_msg = time.localtime(message.date).tm_hour
            din_elec = int(msg[1])
            # проверяем что сегодня не выходной и время меньше чем час обеда в этом чате
            if week_day not in (5, 6) and hour_msg < utils.getSettings(
                    cid, 'elec_end_hour'):
                bot.send_chat_action(cid, 'typing')
                utils.vote_func(din_elec, bot, message)
            else:
                bot.reply_to(message, cfg.too_late_err)
        else:
            bot.send_message(cid,
                             cfg.err_wrong_cmd.format('vote [+/-]NN'),
                             parse_mode='HTML')
    except Exception as e:
        print('***ERROR: Проблема с командой vote_cmd***')
        print('Exception text: ' + str(e))