예제 #1
0
파일: birthday.py 프로젝트: nbr23/nemubot
def cmd_anniv(msg):
    (matches, name) = findName(msg)
    if len(matches) == 1:
        name = matches[0]
        tyd = context.data.index[name].getDate("born")
        tyd = datetime(date.today().year, tyd.month, tyd.day)

        if (tyd.day == datetime.today().day and
            tyd.month == datetime.today().month):
            return Response(countdown_format(
                context.data.index[name].getDate("born"), "",
                "C'est aujourd'hui l'anniversaire de %s !"
                " Il a %s. Joyeux anniversaire :)" % (name, "%s")),
                            msg.channel)
        else:
            if tyd < datetime.today():
                tyd = datetime(date.today().year + 1, tyd.month, tyd.day)

            return Response(countdown_format(tyd,
                            "Il reste %s avant l'anniversaire de %s !" % ("%s",
                                                                    name), ""),
                            msg.channel)
    else:
        return Response("désolé, je ne connais pas la date d'anniversaire"
                        " de %s. Quand est-il né ?" % name,
                        msg.channel, msg.frm)
예제 #2
0
def cmd_anniv(msg):
    (matches, name) = findName(msg)
    if len(matches) == 1:
        name = matches[0]
        tyd = context.data.index[name].getDate("born")
        tyd = datetime(date.today().year, tyd.month, tyd.day)

        if (tyd.day == datetime.today().day
                and tyd.month == datetime.today().month):
            return Response(
                countdown_format(
                    context.data.index[name].getDate("born"), "",
                    "C'est aujourd'hui l'anniversaire de %s !"
                    " Il a %s. Joyeux anniversaire :)" % (name, "%s")),
                msg.channel)
        else:
            if tyd < datetime.today():
                tyd = datetime(date.today().year + 1, tyd.month, tyd.day)

            return Response(
                countdown_format(
                    tyd,
                    "Il reste %s avant l'anniversaire de %s !" % ("%s", name),
                    ""), msg.channel)
    else:
        return Response(
            "désolé, je ne connais pas la date d'anniversaire"
            " de %s. Quand est-il né ?" % name, msg.channel, msg.frm)
예제 #3
0
def cmd_we(msg):
    ndate = datetime.now(timezone.utc) + timedelta(5 - datetime.today().weekday())
    ndate = datetime(ndate.year, ndate.month, ndate.day, 0, 0, 1, 0, timezone.utc)
    return Response(countdown_format(ndate,
                             "Il reste %s avant le week-end, courage ;)",
                             "Youhou, on est en week-end depuis %s."),
                    channel=msg.channel)
예제 #4
0
def cmd_gouter(msg):
    ndate = datetime.now(timezone.utc)
    ndate = datetime(ndate.year, ndate.month, ndate.day, 16, 42, 0, 0, timezone.utc)
    return Response(countdown_format(ndate,
                             "Le goûter aura lieu dans %s, préparez vos biscuits !",
                             "Nous avons %s de retard pour le goûter :("),
                    channel=msg.channel)
예제 #5
0
def cmd_gouter(msg):
    ndate = datetime.now(timezone.utc)
    ndate = datetime(ndate.year, ndate.month, ndate.day, 16, 42, 0, 0,
                     timezone.utc)
    return Response(countdown_format(
        ndate, "Le goûter aura lieu dans %s, préparez vos biscuits !",
        "Nous avons %s de retard pour le goûter :("),
                    channel=msg.channel)
예제 #6
0
def cmd_we(msg):
    ndate = datetime.now(
        timezone.utc) + timedelta(5 - datetime.today().weekday())
    ndate = datetime(ndate.year, ndate.month, ndate.day, 0, 0, 1, 0,
                     timezone.utc)
    return Response(countdown_format(
        ndate, "Il reste %s avant le week-end, courage ;)",
        "Youhou, on est en week-end depuis %s."),
                    channel=msg.channel)
예제 #7
0
def cmd_timetoyear(msg, cur):
    yr = int(msg.cmd)

    if yr == cur:
        return None

    return Response(countdown_format(datetime(yr, 1, 1, 0, 0, 1, 0,
                                              timezone.utc),
                                     "Il reste %s avant %d." % ("%s", yr),
                                     "Le premier janvier %d est passé "
                                     "depuis %s !" % (yr, "%s")),
                    channel=msg.channel)
예제 #8
0
파일: birthday.py 프로젝트: nbr23/nemubot
def cmd_age(msg):
    (matches, name) = findName(msg)
    if len(matches) == 1:
        name = matches[0]
        d = context.data.index[name].getDate("born")

        return Response(countdown_format(d,
                                         "%s va naître dans %s." % (name, "%s"),
                                         "%s a %s." % (name, "%s")),
                        msg.channel)
    else:
        return Response("désolé, je ne connais pas l'âge de %s."
                        " Quand est-il né ?" % name, msg.channel, msg.frm)
    return True
예제 #9
0
def cmd_age(msg):
    (matches, name) = findName(msg)
    if len(matches) == 1:
        name = matches[0]
        d = context.data.index[name].getDate("born")

        return Response(
            countdown_format(d, "%s va naître dans %s." % (name, "%s"),
                             "%s a %s." % (name, "%s")), msg.channel)
    else:
        return Response(
            "désolé, je ne connais pas l'âge de %s."
            " Quand est-il né ?" % name, msg.channel, msg.frm)
    return True
예제 #10
0
def parseanswer(msg):
    res = Response(channel=msg.channel)

    # Avoid message starting by ! which can be interpreted as command by other bots
    if msg.cmd[0] == "!":
        res.nick = msg.nick

    if context.data.index[msg.cmd].name == "strend":
        if context.data.index[msg.cmd].hasAttribute("end"):
            res.append_message("%s commencé il y a %s et se terminera dans %s." % (msg.cmd, countdown(msg.date - context.data.index[msg.cmd].getDate("start")), countdown(context.data.index[msg.cmd].getDate("end") - msg.date)))
        else:
            res.append_message("%s commencé il y a %s." % (msg.cmd, countdown(msg.date - context.data.index[msg.cmd].getDate("start"))))
    else:
        res.append_message(countdown_format(context.data.index[msg.cmd].getDate("start"), context.data.index[msg.cmd]["msg_before"], context.data.index[msg.cmd]["msg_after"]))
    return res
예제 #11
0
파일: events.py 프로젝트: nbr23/nemubot
def parseanswer(msg):
    res = Response(channel=msg.channel)

    # Avoid message starting by ! which can be interpreted as command by other bots
    if msg.cmd[0] == "!":
        res.nick = msg.frm

    if msg.cmd in context.data:
        if context.data[msg.cmd].end:
            res.append_message("%s commencé il y a %s et se terminera dans %s." % (msg.cmd, countdown(msg.date - context.data[msg.cmd].start), countdown(context.data[msg.cmd].end - msg.date)))
        else:
            res.append_message("%s commencé il y a %s." % (msg.cmd, countdown(msg.date - context.data[msg.cmd].start)))
    else:
        res.append_message(countdown_format(context.data[msg.cmd].start, context.data[msg.cmd]["msg_before"], context.data[msg.cmd]["msg_after"]))
    return res
예제 #12
0
def parseanswer(msg):
    res = Response(channel=msg.channel)

    # Avoid message starting by ! which can be interpreted as command by other bots
    if msg.cmd[0] == "!":
        res.nick = msg.frm

    if msg.cmd in context.data:
        if context.data[msg.cmd].end:
            res.append_message(
                "%s commencé il y a %s et se terminera dans %s." %
                (msg.cmd, countdown(msg.date - context.data[msg.cmd].start),
                 countdown(context.data[msg.cmd].end - msg.date)))
        else:
            res.append_message(
                "%s commencé il y a %s." %
                (msg.cmd, countdown(msg.date - context.data[msg.cmd].start)))
    else:
        res.append_message(
            countdown_format(context.data[msg.cmd].start,
                             context.data[msg.cmd]["msg_before"],
                             context.data[msg.cmd]["msg_after"]))
    return res
예제 #13
0
def cmd_newyear(msg):
    return Response(countdown_format(datetime(yrn, 1, 1, 0, 0, 1, 0,
                                              timezone.utc),
                                     "Il reste %s avant la nouvelle année.",
                                     "Nous faisons déjà la fête depuis %s !"),
                    channel=msg.channel)