bitbot-3.11-fork/modules/ctcp.py

29 lines
1.1 KiB
Python
Raw Normal View History

2016-03-31 11:10:51 +00:00
import datetime
from src import IRCBot, ModuleManager, utils
2016-03-29 11:56:58 +00:00
VERSION_DEFAULT = "BitBot %s (https://git.io/bitbot)" % IRCBot.VERSION
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))
2016-03-29 11:56:58 +00:00
@utils.hook("received.ctcp.ping.private")
def ctcp_ping(self, event):
event["user"].send_ctcp_response("PING", event["message"])
2016-03-29 11:56:58 +00:00
@utils.hook("received.ctcp.time.private")
def ctcp_time(self, event):
event["user"].send_ctcp_response("TIME",
datetime.datetime.now().strftime("%c"))