コード例 #1
0
ファイル: bot_engine.py プロジェクト: vcslav-v/tgame_engine
def user_info(user: models.User, tg_id: int):
    try:
        target_user = db_tools.get_user(tg_id)
    except:
        return
    if not target_user:
        return
    if target_user.queue_message:
        place_queue = db_tools.session.query(models.QueueMessage).filter_by(
            user=target_user, ).first()
        message = place_queue.message
        referal_need = place_queue.referal_need
    else:
        message, referal_need = 'No', 'No'

    text = '''
    Игрок - {tg_id}
    Сейчас на  - {point}
    Привёл - {referal_quantity}
    В очереди - {message}
    referal_need - {referal_need}
    '''.format(
        tg_id=target_user.telegram_id,
        point=target_user.point,
        referal_quantity=target_user.referal_quantity,
        message=message,
        referal_need=referal_need,
    )
    bot.send_message(user.telegram_id, text)
コード例 #2
0
ファイル: bot_engine.py プロジェクト: vcslav-v/tgame_engine
def check_command(user: models.User, message: str):
    if message[:4] == 'kuku':
        if message[4:7] == 'inf':
            try:
                tg_id_target = int(message[7:].strip())
            except:
                return
            user_info(user, tg_id_target)
        elif message[4:7] == 'sgp':
            point, tg_user_id = message[7:].strip().split('-')
            try:
                target_user = db_tools.get_user(tg_user_id)
            except:
                return
            db_tools.set_story_point(target_user, point)
    else:
        tell_story(user, message)
コード例 #3
0
def text(msg):
    user = db_tools.get_user(msg.from_user.id)
    if msg.from_user.id == int(config.MASTER_USER):
        bot_engine.check_command(user, msg.text)
    elif not user.is_queue_overflow():
        bot_engine.tell_story(user, msg.text)
コード例 #4
0
def hi_msg(msg):
    try:
        user = db_tools.get_user(msg.from_user.id, msg.text)
    except:
        return
    bot_engine.tell_story(user)
コード例 #5
0
def stats(msg):
    if msg.from_user.id == int(config.MASTER_USER):
        user = db_tools.get_user(msg.from_user.id)
        bot_engine.stats(user)
コード例 #6
0
def add_friend(msg):
    if msg.from_user.id == int(config.MASTER_USER):
        user = db_tools.get_user(msg.from_user.id)
        db_tools.clean_queue(msg.from_user.id)
        db_tools.add_referal('fstart={t_id}'.format(t_id=user.telegram_id))
        bot_engine.bot.send_message(user.telegram_id, 'Добавили реферала')
コード例 #7
0
def hard_reset(msg):
    if msg.from_user.id == int(config.MASTER_USER):
        db_tools.clean_queue(msg.from_user.id)
        user = db_tools.get_user(msg.from_user.id)
        db_tools.delete_user(user)
コード例 #8
0
def restart(msg):
    user = db_tools.get_user(msg.from_user.id)
    db_tools.clean_queue(msg.from_user.id)
    db_tools.restart_story(user)
    bot_engine.tell_story(user)