Skip to content

Commit 8d0f0ee

Browse files
committed
Add hook to match common bot command chars
1 parent 9695e58 commit 8d0f0ee

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

plugins/core_out.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from cloudbot import hook
66
from cloudbot.hook import Priority
7+
from cloudbot.util import colors
78

89
NEW_LINE_TRANS_TBL = str.maketrans({
910
'\r': None,
@@ -41,3 +42,15 @@ def encode_line(line, conn):
4142
encoding = conn.config.get("encoding", "utf-8")
4243
errors = conn.config.get("encoding_errors", "replace")
4344
return line.encode(encoding, errors)
45+
46+
47+
@hook.irc_out(priority=Priority.HIGH)
48+
def strip_command_chars(parsed_line, conn, line):
49+
chars = conn.config.get("strip_cmd_chars", "!.@;$")
50+
if chars and parsed_line and parsed_line.command == "PRIVMSG" and parsed_line.parameters[-1][0] in chars:
51+
new_msg = colors.parse("$(red)[!!]$(clear) ") + parsed_line.parameters[-1]
52+
parsed_line.parameters[-1] = new_msg
53+
parsed_line.has_trail = True
54+
return parsed_line
55+
56+
return line

0 commit comments

Comments
 (0)