Пример #1
0
def listen_msg(massage):
    user_from_db = return_user(massage.chat.id)
    if not user_from_db:
        try:
            if len(res.get(massage.chat.id)) < 4:
                res.get(massage.chat.id).append(massage.text)
                bot.send_message(massage.chat.id,
                                 "Вы вели {0}, введите ещё название или нажмите /done".format(massage.text))
            elif len(res.get(massage.chat.id)) == 4:
                res.get(massage.chat.id).append(massage.text)
                r = ", ".join(res.get(massage.chat.id))
                bot.send_message(massage.chat.id,
                                 "Ваш портфель акций: {0}.\nНажмите /info, чтобы начать получать новости о них!"
                                 "\nИли /repeat, чтобы повторить ввод.".format(r))
            else:
                r = ", ".join(res.get(massage.chat.id))
                bot.send_message(massage.chat.id,
                                 "Ваш портфель акций: {0}.\nНажмите /info, чтобы начать получать новости о них!"
                                 "\nИли /repeat, чтобы повторить ввод.".format(r))
        except:
            bot.send_message(massage.chat.id, "Упс, {0.first_name},что-то пошло не так😢".format(massage.from_user))
    else:
        bot.send_message(massage.chat.id, "Чтобы посмотреть свой портфель нажмите /my_bag."
                                          "\nЧтобы получить последние новости нажмите /info."
                                          "\nЧтобы изменить свой портфель нажмите /change.")
Пример #2
0
def help_command(massage):
    # murkup = types.ReplyKeyboardMarkup(resize_keyboard=True)
    # item1 = types.KeyboardButton("🔎Поиск новостей ")
    # item2 = types.KeyboardButton("💼Ваш портфель")
    # item3 = types.KeyboardButton("🆕Задать новый портфель")
    # murkup.add(item1, item2, item3)

    user_from_db = return_user(massage.chat.id)
    if not user_from_db:
        res.update({massage.chat.id: []})
        bot.send_message(
            massage.chat.id,
            "Введите название или тикер акций (до 5  штук), затем нажмите /done"
            "\nОзнакомиться с название компаний или их тикерами можно здесь👇")
        bot.send_message(massage.chat.id,
                         "https://ffin.ru/market/directory/data/")
    else:
        res.update({user_from_db[0]: user_from_db[2:]})
        bot.send_message(
            massage.chat.id,
            "Здравствуйте, <b>{0.first_name}</b>."
            "\nВы уже общались с ботом, чтобы посмотреть свой портфель нажмите /my_bag."
            "\nЧтобы получить последние новости нажмите /info."
            "\nЧтобы изменить свой портфель нажмите /change.".format(
                massage.from_user),
            parse_mode='html')
Пример #3
0
def get_bag(massage):
    try:
        user_from_db = return_user(massage.chat.id)
        if not user_from_db:
            bot.send_message(massage.chat.id, "{0.first_name}, вы ещё не задали свой портфель."
                                              "\nВведите название или тикер акций (до 5  штук), "
                                              "затем нажмите /done".format(massage.from_user))
        else:
            r = ", ".join(user_from_db[2:])
            bot.send_message(massage.chat.id,
                             "Ваш портфель акций: {0}.\nНажмите /info, чтобы начать получать новости о них!".format(r))
    except:
        bot.send_message(massage.chat.id, "Упс, что-то пошло не так😢")
Пример #4
0
def help_command(massage):
    user_from_db = return_user(massage.chat.id)
    if not user_from_db:
        res.update({massage.chat.id: []})
        bot.send_message(massage.chat.id, "Введите название или тикер акций (до 5  штук), затем нажмите /done"
                                          "\nОзнакомиться с название компаний или их тикерами можно здесь👇")
        bot.send_message(massage.chat.id, "https://ffin.ru/market/directory/data/")
    else:
        res.update({user_from_db[0]: user_from_db[2:]})
        bot.send_message(massage.chat.id, "Здравствуйте, <b>{0.first_name}</b>."
                                          "\nВы уже общались с ботом, чтобы посмотреть свой портфель нажмите /my_bag."
                                          "\nЧтобы получить последние новости нажмите /info."
                                          "\nЧтобы изменить свой портфель нажмите /change.".format(massage.from_user),
                         parse_mode='html')
Пример #5
0
def change_bag(massage):
    try:
        user_from_db = return_user(massage.chat.id)
        if not user_from_db:
            bot.send_message(massage.chat.id, "{0.first_name}, вы ещё не задали свой портфель."
                                              "\nВведите название или тикер акций (до 5  штук), "
                                              "затем нажмите /done".format(massage.from_user))
        else:
            del_user(massage.chat.id)
            bot.send_message(massage.chat.id, "{0.first_name}, ваш портфель акций был удален."
                                              "\nВведите название или тикер акций (до 5  штук), "
                                              "затем нажмите /done".format(massage.from_user))
            res.update({massage.chat.id: []})
    except:
        bot.send_message(massage.chat.id, "Упс, что-то пошло не так😢")
Пример #6
0
def get_info(massage):
    try:
        user_from_db = return_user(massage.chat.id)
        if not user_from_db:
            add_new_user(massage.from_user.id, massage.from_user.first_name, res.get(massage.chat.id))
        else:
            res.update({user_from_db[0]: user_from_db[2:]})
        bot.send_message(massage.chat.id, "Пожалуйста, подождите немного, я ищу 🔎")
        new_res=res.get(massage.chat.id)
        if new_res:
            length = len(res.get(massage.chat.id))
            arr = make_all(res.get(massage.chat.id))
            send_info(arr, length, massage.chat.id)
        else:
            bot.send_message(massage.chat.id, "Упс, что-то пошло не так😢\nНажмите /start для начала работы.")
    except:
        bot.send_message(massage.chat.id, "Упс, что-то пошло не так😢\nНажмите /start для начала работы.")