Пример #1
0
async def user_check(session: CommandSession):
    qq = session.ctx['user_id']
    group_id = session.ctx['group_id']
    id = 0
    money = 0
    help_cnt = 10

    mysql_operate = MysqlOp()
    await mysql_operate.init_mysql()
    user_row = await mysql_operate.select_one(
        "select * from user "
        "where qq = %s and qq_group_id = %s",
        (qq, group_id)
    )

    logger.debug(user_row)

    if user_row is None:
        await mysql_operate.op_sql(
            "insert into user(qq, qq_group_id) "
            "values (%s, %s)",
            (qq, group_id)
        )
        id = mysql_operate.cur.lastrowid
    else:
        id = user_row['id']
        money = user_row['money']
        help_cnt = user_row['help_count']

    return id, money, qq, help_cnt
Пример #2
0
async def _(session: CommandSession):
    mysql_operate = MysqlOp()
    await mysql_operate.init_mysql()
    await mysql_operate.op_sql(
        "update user set help_count = 10 "
        "where qq_group_id = %s", (session.ctx['group_id']))
    session.finish('已重置')
Пример #3
0
async def update(record: Record, group_id: str):
    logger.debug(group_id)
    mysql_operate = MysqlOp()
    await mysql_operate.init_mysql()
    for k, v in record.user_list.items():
        await mysql_operate.op_sql(
            "update user set money = money + %s "
            "where qq = %s and qq_group_id = %s",
            (v[2], k, group_id)
        )
Пример #4
0
async def _(session: RequestSession):
    if session.ctx['sub_type'] == 'invite' \
            and session.ctx['user_id'] == 137959742:
        await session.approve()
        group_id = session.ctx['group_id']
        group_info = await get_bot().get_group_info(group_id=group_id)
        mysql_operate = MysqlOp()
        await mysql_operate.init_mysql()
        await mysql_operate.insert_many(
            "insert into qq_group(group_id, group_name, approve_time) "
            "VALUES (%s, %s, %s)",
            (group_id, group_info['group_name'], get_time_pin())
        )
        return
Пример #5
0
async def _(session: CommandSession):
    bot = get_bot()
    try:
        await bot.set_group_leave(
            group_id=session.ctx['group_id'],
            is_dismiss=True
        )
        mysql_operate = MysqlOp()
        await mysql_operate.init_mysql()
        await mysql_operate.op_sql(
            "delete from qq_group "
            "where group_id = %s",
            (session.ctx['group_id'])
        )
    except:
        session.finish("退群失败!")
Пример #6
0
async def _(session: CommandSession):
    """
    排行榜类似的功能,显示金额排行
    :param session:
    :return:
    """
    await check_group(session)
    mysql_operate = MysqlOp()
    await mysql_operate.init_mysql()
    u_list = await mysql_operate.select_all(
        "select * from user "
        "where qq_group_id = %s "
        "order by money desc", (session.ctx['group_id']))
    group_list = await get_bot().get_group_member_list(
        group_id=session.ctx['group_id'])
    group_dict = {}
    for u in group_list:
        group_dict[u['user_id']] = u['card'] \
            if u['card'] != '' else u['nickname']

    ans = '江江江江!本群土豪排名公布~\n'
    cnt = 0
    anonymous = session.ctx['anonymous']
    user_id = session.ctx['user_id']
    for u in u_list:
        if group_dict.get(u['qq']) is None:
            continue

        cnt += 1

        if cnt > 20:
            if anonymous is None and user_id == u['qq']:
                ans += f"你是第{cnt}名 现有财产{u['money']}$"
                break
            continue

        ans += f"第{cnt}名: {group_dict[u['qq']]} 现有财产:{u['money']}$\n"

    session.finish(ans)
Пример #7
0
async def _(session: CommandSession):
    """
    如果没钱了就来个救济金每天10次
    :param session:
    :return:
    """
    await check_group(session)
    await anonymous_check(session)
    id, money, qq, help_cnt = await user_check(session)
    if help_cnt > 0:
        if money == 0:
            mysql_operate = MysqlOp()
            await mysql_operate.init_mysql()
            await mysql_operate.op_sql(
                'update user set money = money + 20, '
                'help_count = help_count - 1 '
                'where qq = %s and qq_group_id = %s',
                (qq, session.ctx['group_id']))
            session.finish(f'已成功为您发放救济金20$!' f'当前剩余救济金次数:{help_cnt - 1}')
        else:
            session.finish('您的资产并不为0,不能领取救济金!')
    else:
        session.finish('您今天的救济金次数已用尽!')
Пример #8
0
async def _():
    mysql_operate = MysqlOp()
    await mysql_operate.init_mysql()
    await mysql_operate.op_sql("update user set help_count = 10")
    logger.info('已重置!')