コード例 #1
0
ファイル: events.py プロジェクト: pombredanne/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
コード例 #2
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
コード例 #3
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
コード例 #4
0
ファイル: events.py プロジェクト: nbr23/nemubot
def end_countdown(msg):
    if len(msg.args) < 1:
        raise IMException("quel événement terminer ?")

    if msg.args[0] in context.data:
        if context.data[msg.args[0]].creator == msg.frm or (msg.cmd == "forceend" and msg.frm_owner):
            duration = countdown(msg.date - context.data[msg.args[0]].start)
            del context.data[msg.args[0]]
            context.save()
            return Response("%s a duré %s." % (msg.args[0], duration),
                            channel=msg.channel, nick=msg.frm)
        else:
            raise IMException("Vous ne pouvez pas terminer le compteur %s, créé par %s." % (msg.args[0], context.data[msg.args[0]].creator))
    else:
        return Response("%s n'est pas un compteur connu."% (msg.args[0]), channel=msg.channel, nick=msg.frm)
コード例 #5
0
def end_countdown(msg):
    if len(msg.args) < 1:
        raise IMException("quel événement terminer ?")

    if msg.args[0] in context.data.index:
        if context.data.index[msg.args[0]]["proprio"] == msg.nick or (msg.cmd == "forceend" and msg.frm_owner):
            duration = countdown(msg.date - context.data.index[msg.args[0]].getDate("start"))
            context.del_event(context.data.index[msg.args[0]]["_id"])
            context.data.delChild(context.data.index[msg.args[0]])
            context.save()
            return Response("%s a duré %s." % (msg.args[0], duration),
                            channel=msg.channel, nick=msg.nick)
        else:
            raise IMException("Vous ne pouvez pas terminer le compteur %s, créé par %s." % (msg.args[0], context.data.index[msg.args[0]]["proprio"]))
    else:
        return Response("%s n'est pas un compteur connu."% (msg.args[0]), channel=msg.channel, nick=msg.nick)
コード例 #6
0
ファイル: events.py プロジェクト: pombredanne/nemubot
def end_countdown(msg):
    if len(msg.args) < 1:
        raise IMException("quel événement terminer ?")

    if msg.args[0] in context.data:
        if context.data[msg.args[0]].creator == msg.frm or (
                msg.cmd == "forceend" and msg.frm_owner):
            duration = countdown(msg.date - context.data[msg.args[0]].start)
            del context.data[msg.args[0]]
            context.save()
            return Response("%s a duré %s." % (msg.args[0], duration),
                            channel=msg.channel,
                            nick=msg.frm)
        else:
            raise IMException(
                "Vous ne pouvez pas terminer le compteur %s, créé par %s." %
                (msg.args[0], context.data[msg.args[0]].creator))
    else:
        return Response("%s n'est pas un compteur connu." % (msg.args[0]),
                        channel=msg.channel,
                        nick=msg.frm)