Example #1
0
async def report_total(session: CommandSession):
    group_id = session.ctx['group_id']
    group_info = await session.bot.get_group_info(group_id=group_id)
    group_name = group_info['group_name']
    member_count = group_info['member_count']

    dm = DataManager(group_id)

    starttime = long_long_ago()
    endtime = cstnow()

    data = dm.report(starttime, endtime)
    data = [[alias, ac_now] for alias, _, ac_now in data if ac_now > 0]

    data.sort(reverse=True, key=itemgetter(1))

    lines = autoalign(data, formatter=lambda x: "| {} | {:<5} |".format(*x))

    entries = min(member_count, REPORT_TOTAL_MAX_ENTRIES, len(data))
    header = f"{group_name} Top {entries} / {member_count}\n"
    header += "# | Name | Accepted |"
    await session.send(header)

    for msg in multiline_msg_generator(lines[:entries], lineno=True):
        await session.bot.send_msg_rate_limited(group_id=group_id, message=msg)
Example #2
0
async def report(session: CommandSession):
    group_id = session.ctx['group_id']

    dm = DataManager(group_id)

    starttime = last_sunday()
    endtime = cstnow()

    data = dm.report(starttime, endtime)
    data = [[alias, ac_now, ac_now - ac_before] for alias, ac_before, ac_now in data if ac_now > 0]

    data.sort(reverse=True, key=itemgetter(2, 1))

    lines = autoalign(data, formatter=lambda x: "| {} | {:<5} (+{}) |".format(*x))

    header = f"{starttime} - {endtime}\n"
    header += "| Name | Accepted (+delta) |"
    await session.send(header)

    for msg in multiline_msg_generator(lines, lineno=True):
        await session.bot.send_msg_rate_limited(group_id=group_id, message=msg)