Added a setting to disable ctcp responses
This commit is contained in:
parent
2e9ce67586
commit
fda3d65d53
1 changed files with 20 additions and 19 deletions
|
@ -8,24 +8,25 @@ class Module(object):
|
||||||
|
|
||||||
def private_message(self, event):
|
def private_message(self, event):
|
||||||
if event["message"][0] == "\x01" and event["message"][-1] == "\x01":
|
if event["message"][0] == "\x01" and event["message"][-1] == "\x01":
|
||||||
ctcp_command = event["message_split"][0][1:].upper()
|
if event["server"].get_setting("ctcp-responses", True):
|
||||||
if ctcp_command.endswith("\x01"):
|
ctcp_command = event["message_split"][0][1:].upper()
|
||||||
ctcp_command = ctcp_command[:-1]
|
if ctcp_command.endswith("\x01"):
|
||||||
ctcp_args = " ".join(event["message_split"][1:])[:-1]
|
ctcp_command = ctcp_command[:-1]
|
||||||
ctcp_args_split = ctcp_args.split(" ")
|
ctcp_args = " ".join(event["message_split"][1:])[:-1]
|
||||||
|
ctcp_args_split = ctcp_args.split(" ")
|
||||||
|
|
||||||
ctcp_response = None
|
ctcp_response = None
|
||||||
if ctcp_command == "VERSION":
|
if ctcp_command == "VERSION":
|
||||||
ctcp_response = self.bot.config.get("ctcp-version",
|
ctcp_response = self.bot.config.get("ctcp-version",
|
||||||
"BitBot (https://github.com/jesopo/bitbot)")
|
"BitBot (https://github.com/jesopo/bitbot)")
|
||||||
elif ctcp_command == "SOURCE":
|
elif ctcp_command == "SOURCE":
|
||||||
ctcp_response = self.bot.config.get("ctcp-source",
|
ctcp_response = self.bot.config.get("ctcp-source",
|
||||||
"https://github.com/jesopo/bitbot")
|
"https://github.com/jesopo/bitbot")
|
||||||
elif ctcp_command == "PING":
|
elif ctcp_command == "PING":
|
||||||
ctcp_response = " ".join(ctcp_args_split)
|
ctcp_response = " ".join(ctcp_args_split)
|
||||||
elif ctcp_command == "TIME":
|
elif ctcp_command == "TIME":
|
||||||
ctcp_response = datetime.datetime.now().strftime("%c")
|
ctcp_response = datetime.datetime.now().strftime("%c")
|
||||||
|
|
||||||
if ctcp_response:
|
if ctcp_response:
|
||||||
event["user"].send_ctcp_response(ctcp_command,
|
event["user"].send_ctcp_response(ctcp_command,
|
||||||
ctcp_response)
|
ctcp_response)
|
||||||
|
|
Loading…
Reference in a new issue