2016-03-31 11:10:51 +00:00
|
|
|
import datetime
|
2018-10-03 12:22:37 +00:00
|
|
|
from src import ModuleManager, utils
|
2016-03-29 11:56:58 +00:00
|
|
|
|
2019-02-12 16:49:57 +00:00
|
|
|
VERSION_DEFAULT = "BitBot (https://git.io/bitbot)"
|
|
|
|
SOURCE_DEFAULT = "https://git.io/bitbot"
|
|
|
|
|
2018-10-03 12:22:37 +00:00
|
|
|
@utils.export("serverset", {"setting": "ctcp-responses",
|
2018-09-27 11:08:07 +00:00
|
|
|
"help": "Set whether I respond to CTCPs on this server",
|
2018-10-03 12:22:37 +00:00
|
|
|
"validate": utils.bool_or_none})
|
2018-09-27 11:08:07 +00:00
|
|
|
class Module(ModuleManager.BaseModule):
|
2019-02-12 16:49:57 +00:00
|
|
|
@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
|
|
|
|
2019-02-12 16:49:57 +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
|
|
|
|
2019-02-12 16:49:57 +00:00
|
|
|
@utils.hook("received.ctcp.time.private")
|
|
|
|
def ctcp_time(self, event):
|
|
|
|
event["user"].send_ctcp_response("TIME",
|
2019-02-12 16:55:56 +00:00
|
|
|
datetime.datetime.now().strftime("%c"))
|