Пример #1
0
async def monitor_arc_users(client):
    await client.wait_until_ready()
    while not client.is_closed:
        ark_alerts = client.get_channel(ARK_ALERTS_CHAN_ID)
        ark_tracked_users = [
            steam.user_on_ark(user_id)
            for user_id in data.get('ark.tracked_users', [])
        ]
        new_online_usernames = []
        for online, user_id, name in ark_tracked_users:
            if not online and user_id in data.get('ark.online_users', []):
                data.get('ark.online_users', []).remove(user_id)
            elif online and user_id not in data.get('ark.online_users', []):
                data.get('ark.online_users', []).append(user_id)
                new_online_usernames.append(name)
        data.save()

        if new_online_usernames:
            callouts = data.get('ark.user_alert_callouts', [])
            msg = ('{callout} Ark online user alert for: {users}'.format(
                callout=' '.join(callouts),
                users=', '.join(new_online_usernames)))
            await client.send_message(ark_alerts, msg)

        await asyncio.sleep(60)
Пример #2
0
async def cmd_ark_user_alert_off(client, message):
    callout = message.author.mention
    callouts = data.get('ark.user_alert_callouts', [])
    if callout in callouts:
        callouts.remove(callout)
        data.save()
    msg = "Ok, I won't send you Ark user alerts"
    await client.send_message(message.channel, msg)
Пример #3
0
async def cmd_ark_user_survey(client, message):
    tracked_users = [steam.user_on_ark(user_id) for user_id in
                     data.get('ark.tracked_users', [])]
    lines = ['{} ({}): {}'.format(name, user_id,
                                  'online' if online else 'offline')
             for (online, user_id, name) in tracked_users]
    msg = '\n'.join(lines)
    await client.send_message(message.channel, msg)
Пример #4
0
async def cmd_ark_user_alert_off(client, message):
    callout = message.author.mention
    callouts = data.get('ark.user_alert_callouts', [])
    if callout in callouts:
        callouts.remove(callout)
        data.save()
    msg = "Ok, I won't send you Ark user alerts"
    await client.send_message(message.channel, msg)
Пример #5
0
async def cmd_ark_user_survey(client, message):
    tracked_users = [
        steam.user_on_ark(user_id)
        for user_id in data.get('ark.tracked_users', [])
    ]
    lines = [
        '{} ({}): {}'.format(name, user_id, 'online' if online else 'offline')
        for (online, user_id, name) in tracked_users
    ]
    msg = '\n'.join(lines)
    await client.send_message(message.channel, msg)
Пример #6
0
async def cmd_untrack_ark_user(client, message):
    args = message.content.split(' ')[1:]
    if len(args) != 1:
        msg = 'Invalid usage! Command is "!untrack_arg_user [steam_user_id]"'
        await client.send_message(message.channel, msg)
    else:
        tracked_users = data.get('ark.tracked_users', [])
        if args[0] in tracked_users:
            tracked_users.remove(args[0])
        data.save()
        msg = 'Stopped tracking user {user}'.format(user=args[0])
        await client.send_message(message.channel, msg)
Пример #7
0
async def cmd_untrack_ark_user(client, message):
    args = message.content.split(' ')[1:]
    if len(args) != 1:
        msg = 'Invalid usage! Command is "!untrack_arg_user [steam_user_id]"'
        await client.send_message(message.channel, msg)
    else:
        tracked_users = data.get('ark.tracked_users', [])
        if args[0] in tracked_users:
            tracked_users.remove(args[0])
        data.save()
        msg = 'Stopped tracking user {user}'.format(user=args[0])
        await client.send_message(message.channel, msg)
Пример #8
0
async def monitor_arc_users(client):
    await client.wait_until_ready()
    while not client.is_closed:
        ark_alerts = client.get_channel(ARK_ALERTS_CHAN_ID)
        ark_tracked_users = [steam.user_on_ark(user_id)
                             for user_id in data.get('ark.tracked_users', [])]
        new_online_usernames = []
        for online, user_id, name in ark_tracked_users:
            if not online and user_id in data.get('ark.online_users', []):
                data.get('ark.online_users', []).remove(user_id)
            elif online and user_id not in data.get('ark.online_users', []):
                data.get('ark.online_users', []).append(user_id)
                new_online_usernames.append(name)
        data.save()

        if new_online_usernames:
            callouts = data.get('ark.user_alert_callouts', [])
            msg = ('{callout} Ark online user alert for: {users}'
                   .format(callout=' '.join(callouts),
                           users=', '.join(new_online_usernames)))
            await client.send_message(ark_alerts, msg)

        await asyncio.sleep(60)
Пример #9
0
async def cmd_nopage(client, message):
    group = message.content.split(' ', 1)[1].lower()
    users = data.get('page_groups.{}'.format(group), [])
    if message.author.name in users:
        users.remove(message.author.mention)
        data.save()
Пример #10
0
async def cmd_page(client, message):
    group = message.content.split(' ', 1)[1].lower()
    users = ', '.join(data.get('page_groups.{}'.format(group), []))
    if users:
        await client.send_message(message.channel, 'Paging: {}'.format(users))
Пример #11
0
async def cmd_nopage(client, message):
    group = message.content.split(' ', 1)[1].lower()
    users = data.get('page_groups.{}'.format(group), [])
    if message.author.name in users:
        users.remove(message.author.mention)
        data.save()
Пример #12
0
async def cmd_page(client, message):
    group = message.content.split(' ', 1)[1].lower()
    users = ', '.join(data.get('page_groups.{}'.format(group), []))
    if users:
        await client.send_message(message.channel, 'Paging: {}'.format(users))