aboutsummaryrefslogtreecommitdiff
path: root/modules/ctcp.py
blob: 339ac3547f599290d1e29cddd5693ab6fea772ae (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import datetime
from src import ModuleManager, utils

VERSION_DEFAULT = "BitBot (https://git.io/bitbot)"
SOURCE_DEFAULT = "https://git.io/bitbot"

@utils.export("serverset", {"setting": "ctcp-responses",
    "help": "Set whether I respond to CTCPs on this server",
    "validate": utils.bool_or_none})
class Module(ModuleManager.BaseModule):
    @utils.hook("received.ctcp.version.private")
    def ctcp_version(self, event):
        event["user"].send_ctcp_response("VERSION",
            self.bot.config.get("ctcp-version", VERSION_DEFAULT))

    @utils.hook("received.ctcp.source.private")
    def ctcp_source(self, event):
        event["user"].send_ctcp_response("SOURCE",
            self.bot.config.get("ctcp-source", SOURCE_DEFAULT))

    @utils.hook("received.ctcp.ping.private")
    def ctcp_ping(self, event):
        event["user"].send_ctcp_response("PING", event["message"])

    @utils.hook("received.ctcp.time.private")
    def ctcp_time(self, event):
        event["user"].send_ctcp_response("TIME",
            datetime.datetime.now().strftime("%c"))