2019-05-25 20:40:06 +00:00
|
|
|
#--depends-on config
|
|
|
|
|
2016-03-31 11:10:51 +00:00
|
|
|
import datetime
|
2019-02-24 08:39:20 +00:00
|
|
|
from src import IRCBot, ModuleManager, utils
|
2016-03-29 11:56:58 +00:00
|
|
|
|
2019-02-12 16:49:57 +00:00
|
|
|
|
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",
|
2019-05-23 09:28:14 +00:00
|
|
|
"validate": utils.bool_or_none, "example": "on"})
|
2018-09-27 11:08:07 +00:00
|
|
|
class Module(ModuleManager.BaseModule):
|
2019-06-03 10:03:12 +00:00
|
|
|
@utils.hook("received.ctcp.request.version")
|
2019-02-12 16:49:57 +00:00
|
|
|
def ctcp_version(self, event):
|
2019-05-15 09:30:36 +00:00
|
|
|
default = "BitBot %s (%s)" % (IRCBot.VERSION, IRCBot.SOURCE)
|
|
|
|
|
2019-02-12 16:49:57 +00:00
|
|
|
event["user"].send_ctcp_response("VERSION",
|
2019-05-15 09:30:36 +00:00
|
|
|
self.bot.config.get("ctcp-version", default))
|
2019-02-12 16:49:57 +00:00
|
|
|
|
2019-06-03 10:03:12 +00:00
|
|
|
@utils.hook("received.ctcp.request.source")
|
2019-02-12 16:49:57 +00:00
|
|
|
def ctcp_source(self, event):
|
|
|
|
event["user"].send_ctcp_response("SOURCE",
|
2019-05-15 09:30:36 +00:00
|
|
|
self.bot.config.get("ctcp-source", IRCBot.SOURCE))
|
2016-03-29 11:56:58 +00:00
|
|
|
|
2019-06-03 10:03:12 +00:00
|
|
|
@utils.hook("received.ctcp.request.ping")
|
2019-02-12 16:49:57 +00:00
|
|
|
def ctcp_ping(self, event):
|
|
|
|
event["user"].send_ctcp_response("PING", event["message"])
|
2016-03-29 11:56:58 +00:00
|
|
|
|
2019-06-03 10:03:12 +00:00
|
|
|
@utils.hook("received.ctcp.request.time")
|
2019-02-12 16:49:57 +00:00
|
|
|
def ctcp_time(self, event):
|
|
|
|
event["user"].send_ctcp_response("TIME",
|
2019-02-12 16:55:56 +00:00
|
|
|
datetime.datetime.now().strftime("%c"))
|