def time_remaining(name, eta, plus_minus, window, spawns, accuracy, target):
    now = timeh.now()
    postfix = ""
    prefix = ""
    output = "[" + name + "] "
    approx = " "
    if accuracy <= 0 or spawns > 6:
        approx = "~ "
        if accuracy <= -1 or spawns >= 10:
            approx = "~~ "
    if not plus_minus:
        if now > eta:
            output += "ToD too old. Please update it if you have a chance! "
        else:
            output += "%swill spawn in %s" % (approx, timeh.countdown(
                now, eta))
    else:
        if now > window['end']:
            output += "window is close. Please update ToD if u have a chance! "
        elif now < window['start']:
            output += "%swindow will open in %s " % (approx,
                                                     timeh.countdown(now, eta))
        elif window['start'] <= now <= window['end']:
            prefix = ""
            postfix = "## "
            output += "%sin window until %s " % (approx,
                                                 timeh.countdown(now, eta))
    if target:
        postfix += ".target"
    return prefix + output + postfix + "\n"
Exemple #2
0
    def compose_timers_message(self, merbs, trackers):
        embed_timers = discord.Embed(title=self.title, description=self.description, color=0x444444)

        merbs.order('eta')
        counter_all = counter_in_window = 0
        for merb in merbs.merbs:

            if merb.has_eta() and merb.is_target() and counter_all < 24:
                counter_all = counter_all + 1
                field_content = ""
                name_content = merb.name

                if merb.pop > merb.tod and timeh.now() < merb.window['start']:
                    if not timeh.halfway_to_start_window(merb):
                        name_content = f"{self.emojii_pop} %s" % name_content
                        field_content += " popped %s ago\n" % timeh.countdown(merb.pop, timeh.now())
                    else:
                        field_content += "window roughly opens in %s\n" % timeh.countdown(timeh.now(), merb.eta)
                else:
                    if merb.is_in_window():
                        counter_in_window = counter_in_window + 1
                        name_content = f"{self.emojii_open_window} %s" % name_content
                        field_content += " *__in window__* for the next "
                    else:
                        field_content += "window opens in "

                    field_content += timeh.countdown(timeh.now(), merb.eta) + "\n"

                if merb.plus_minus:
                    active_trackers = merb.get_trackers()
                    if active_trackers:
                        field_content += "Active trackers: "
                        for tracker in active_trackers:

                            try:
                                tracker_name = config.authenticator.users[tracker].name
                                mode = trackers.get_tracker(tracker)['mode']
                                field_content += tracker_name
                                if mode:
                                    field_content += " (%s)" % mode
                                field_content += " - "
                            except:
                                pass
                        field_content = field_content[:-3]
                        field_content += "\n"

                    else:
                        field_content += ""
                field_content += "-"

                embed_timers.add_field(name=name_content, value=field_content, inline=False)

        footer = "%d total, %d in window.\nLast update %s UTC" % (counter_all, counter_in_window, timeh.now().strftime(config.DATE_FORMAT_PRINT))
        embed_timers.set_footer(text=footer)

        return embed_timers
Exemple #3
0
    def assemble_start_tracking_messages(self, what, tracked_merbs, mode=''):
        messages = []
        output_private_content = ''
        if mode:
            mode = f"[{mode}]"

        for merb in tracked_merbs:
            if merb.is_in_window():
                output_private_content += f"You start tracking {merb.name} {mode}\n"
            else:
                time_to_start = timeh.countdown(timeh.now(),
                                                merb.window['start'])
                output_private_content += f"You will start tracking {merb.name} in {time_to_start} {mode}\n"

        output_private_content += "\nRemember to {!track stop} when leaving or {!pop merb} at spawn time.\n" \
                                  "If you want to Batphone please {!pop merb_name BP}"

        messages.append({
            'destination': self.input_author,
            'content': output_private_content,
            'decoration': 'CSS'
        })

        messages.append({
            'destination':
            self.d_client.get_channel(config.BROADCAST_CHANNEL),
            'content':
            f"{self.input_author.name} starts tracking {what.capitalize()} {mode}",
            'decoration':
            'YELLOW'
        })

        return messages
Exemple #4
0
 def get_duration(self, user_id):
     if user_id in self.users:
         return timeh.countdown(
             self.users[user_id][self.get_tracked_merbs(user_id)],
             timeh.now())
     else:
         return None
def track_msg(author, merb, track_mode, time, time_future):

    if not time_future:
        output = "%s starts tracking [%s]  %s" % (author, merb.name, track_mode)
    else:
        time_remaining = timeh.countdown(timeh.now(), time)
        output = "%s will start tracking [%s] in %s %s" % (author, merb.name, time_remaining, track_mode)
    return output
def get_self_track_info(user_id, trackers):
    tracker = trackers.get_tracker(user_id)
    if not tracker:
        return "You are not tracking :("

    output = 'You are tracking: '
    for merb in tracker['merbs']:
        output += "[%s] " % merb.name
    output += "since %s" % timeh.countdown(tracker['date'], timeh.now())
    return output
def print_dkp_tracking_msg(who, what, mode, start_time):
    if start_time > timeh.now():
        total_duration = ""
    else:
        total_duration = "(Total Time: %s)" % timeh.countdown(start_time, timeh.now())

    output_msg = f"{who} tracked {what} "
    if mode:
        output_msg += f"[{mode}] "
    output_msg += f"= {total_duration}"

    return output_msg
def time_remaining(merb, v_target_tag=True):
    now = timeh.now()
    postfix = ""
    prefix = ""
    output = "- [" + merb.name + "] "
    approx = ""
    if merb.accuracy <= 0 or merb.spawns == 1:
        approx = "{roughly} "
    if merb.accuracy <= -1 or merb.spawns > 1:
        approx = "{very roughly} "
    if not merb.plus_minus:
        if now > merb.eta:
            output += "ToD is too old. "
        else:
            output += "will %sspawn in %s " % (approx, timeh.countdown(now, merb.eta))
    else:
        if merb.is_alive():
            output += "popped %s ago " % timeh.countdown(merb.pop, timeh.now())

        elif now > merb.window['end']:
            output += "window is closed "

        elif now < merb.window['start']:
            output += "window will %sopen in %s " % (approx, timeh.countdown(now, merb.eta))

        elif merb.window['start'] <= now <= merb.window['end']:
            prefix = ""
            postfix = "## "
            output += "is %sin .window until %s " % (approx, timeh.countdown(now, merb.eta))

    if merb.spawns >= 1:
        output += "(%s respawn since last update) " % merb.spawns
    if merb.target == "auto" and v_target_tag:
        postfix += ".sticky_target"
    if merb.target == "manual" and v_target_tag:
        postfix += ".new_target"

    return prefix + output + postfix + "\n"
def print_stop_tracking_msg(who, what, mode, start_time):
    output_msg = ''
    if start_time > timeh.now():
        total_duration = ""
    else:
        total_duration = "(Total Time: %s)" % timeh.countdown(start_time, timeh.now())

    if who == 'You':
        output_msg += f"You stop tracking {what} "
    else:
        output_msg += f"{who} stops tracking {what} "
    if mode:
        output_msg += f"[{mode}] "
    output_msg += f"= {total_duration}"

    return output_msg