Exemplo n.º 1
0
def subscribe(message):
    user, session = user_db.get_user(message.from_user.id, message.chat.id)
    user.wants_to_subscribe = True
    user.wants_to_unsubscribe = False
    session.commit()

    bot.send_message(
        message.chat.id,
        'Напиши ид юзера на кого хочешь подписаться пример @genadiy_g')
def publish_twits(twits):
    for twit in twits:
        if twits_db.get_twit(twit.twit_id) is not None:
            continue

        followings = following_db.get_following_by_following_id(twit.following_id)
        for following in followings:
            user = user_db.get_user(following.user_id)[0]
            publish_twit(user.chat_id, twit.twit_text, following.following_id)
Exemplo n.º 3
0
def button_click(message):
    button_cb = COMMANDS.get(message.text, None)
    user, session = user_db.get_user(message.from_user.id, message.chat.id)

    if button_cb is not None:
        button_cb(message)
        return

    if user.get_subscribe_status is not None:
        response_message = resolve_followings_id(user, message.text, session)
        bot.send_message(message.chat.id,
                         response_message,
                         reply_markup=keyboard1)

    session.commit()
Exemplo n.º 4
0
def start_message(message):
    user, session = user_db.get_user(message.from_user.id, message.chat.id)
    response_message = f'Привет, {message.from_user.first_name} я буду пересылать тебе твиты твоих подписок'

    bot.send_message(message.chat.id, response_message, reply_markup=keyboard1)
    session.commit()