Esempio n. 1
0
    def make_active_text(self, server):
        server = normalize_server_name(server)

        server_events = EventList(self.events).with_server(server)
        active_events = server_events.active_only()
        events_today = server_events.today_only(server)

        active_special = active_events.in_dungeon_type([DungeonType.Special])

        msg = server + " Events - " + datetime.datetime.now(
            SERVER_TIMEZONES[server]).strftime('%A, %B%e')

        ongoing_events = active_events.in_length(
            [EventLength.weekly, EventLength.special])
        if ongoing_events:
            msg += "\n\n" + self.make_active_output('Ongoing Events',
                                                    ongoing_events)

        active_dailies_events = active_events.with_length(EventLength.daily)
        if active_dailies_events:
            msg += "\n\n" + self.make_daily_output('Daily Dungeons',
                                                   active_dailies_events)

        limited_events = events_today.with_length(EventLength.limited)
        if limited_events:
            msg += "\n\n" + self.make_full_guerrilla_output(
                'Limited Events', limited_events)

        return msg
Esempio n. 2
0
    async def do_partial(self,
                         ctx,
                         server: Server,
                         group: StarterGroup = None):
        server = server.value

        if group is not None:
            group = GROUPS[group.value]

        events = EventList(self.events)
        events = events.with_server(server)
        events = events.with_dungeon_type(DungeonType.SoloSpecial,
                                          DungeonType.Special)
        events = events.with_length(EventLength.limited)

        active_events = sorted(events.active_only(),
                               key=lambda e: (e.open_datetime, e.dungeon_name),
                               reverse=True)
        pending_events = sorted(events.pending_only(),
                                key=lambda e:
                                (e.open_datetime, e.dungeon_name),
                                reverse=True)

        if group is not None:
            active_events = [
                e for e in active_events if e.group == group.lower()
            ]
            pending_events = [
                e for e in pending_events if e.group == group.lower()
            ]

        group_to_active_event = {e.group: e for e in active_events}
        group_to_pending_event = {e.group: e for e in pending_events}

        active_events.sort(
            key=lambda e: (GROUPS.index(e.group or 'red'), e.open_datetime))
        pending_events.sort(
            key=lambda e: (GROUPS.index(e.group or 'red'), e.open_datetime))

        if len(active_events) == 0 and len(pending_events) == 0:
            await ctx.send("No events available for " + server)
            return

        output = "**Events for {}**".format(server)

        if len(active_events) > 0:
            output += "\n\n" + "`  Remaining Dungeon       - Ending Time`"
            for e in active_events:
                output += "\n" + e.to_partial_event(self)

        if len(pending_events) > 0:
            output += "\n\n" + "`  Dungeon                 - ETA`"
            for e in pending_events:
                output += "\n" + e.to_partial_event(self)

        for page in pagify(output):
            await ctx.send(page)
Esempio n. 3
0
 async def do_autoevent_summary(self, server):
     events = EventList(self.events).with_server(server).today_only('NA')
     for gid, data in (await self.config.all_guilds()).items():
         if (guild := self.bot.get_guild(gid)) is None:
             continue
         channels = defaultdict(list)
         for key, aep in data.get('pingroles', {}).items():
             for channel in aep['channels']:
                 if channel is not None:
                     channels[channel].append(aep)
         for cid, aeps in channels.items():
             if (channel := self.bot.get_channel(cid)) is None:
                 continue
             if not await self.config.channel(channel).do_aep_post():
                 continue
             aepevents = events.with_func(lambda e: any(
                 self.event_matches_autoevent(e, ae) for ae in aeps))
             if not aepevents:
                 continue
             msg = self.make_full_guerrilla_output('AEP Event', aepevents)
             for page in pagify(msg, delims=['\n\n']):
                 with suppress(discord.Forbidden):
                     await channel.send(box(page))
Esempio n. 4
0
    async def do_partial(self,
                         ctx,
                         server: Server,
                         group: StarterGroup = None):
        server = server.value

        if group is not None:
            group = GROUPS[group.value]

        events = EventList(self.events)
        events = events.with_server(server)
        events = events.in_dungeon_type(
            [DungeonType.SoloSpecial, DungeonType.Special])
        events = events.is_grouped()

        active_events = events.active_only().items_by_open_time(reverse=True)
        pending_events = events.pending_only().items_by_open_time(reverse=True)

        if group is not None:
            active_events = [
                e for e in active_events if e.group == group.lower()
            ]
            pending_events = [
                e for e in pending_events if e.group == group.lower()
            ]

        group_to_active_event = {e.group: e for e in active_events}
        group_to_pending_event = {e.group: e for e in pending_events}

        active_events.sort(
            key=lambda e: (GROUPS.index(e.group), e.open_datetime))
        pending_events.sort(
            key=lambda e: (GROUPS.index(e.group), e.open_datetime))

        if len(active_events) == 0 and len(pending_events) == 0:
            await ctx.send("No events available for " + server)
            return

        output = "Events for {}".format(server)

        if len(active_events) > 0:
            output += "\n\n" + "  Remaining Dungeon"
            for e in active_events:
                output += "\n" + e.to_partial_event(self)

        if len(pending_events) > 0:
            output += "\n\n" + "  PT    ET    ETA     Dungeon"
            for e in pending_events:
                output += "\n" + e.to_partial_event(self)

        for page in pagify(output):
            await ctx.send(box(page))