aboutsummaryrefslogtreecommitdiff
path: root/modules/ircv3_msgid.py
blob: 520198d6e55a86668b391cba7aeb06f77822094d (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from src import ModuleManager, utils

TAG = utils.irc.MessageTag("msgid", "draft/msgid")

class Module(ModuleManager.BaseModule):
    def _on_channel(self, channel, tags):
        msgid = TAG.get_value(tags)
        if not msgid == None:
            channel.set_setting("last-msgid", msgid)

    @utils.hook("received.message.channel")
    @utils.hook("received.notice.channel")
    @utils.hook("received.tagmsg.channel")
    def on_channel(self, event):
        self._on_channel(event["channel"], event["tags"])

    @utils.hook("received.ctcp.request")
    @utils.hook("received.ctcp.response")
    def ctcp(self, event):
        if event["is_channel"]:
            self._on_channel(event["target"], event["tags"])