Skip to content

Commit

Permalink
Filtering documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Mottram committed May 23, 2021
1 parent dc88e91 commit 72f9966
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ And you can remove a ban with:

/mode -b #channel [nickname]

Messages can be filtered. Filters can also contain wildcard characters.

/filter add "never gonna give you up"
/filter remove "the * sat on the *"


License
-------
Expand Down
18 changes: 5 additions & 13 deletions miniircd
Original file line number Diff line number Diff line change
Expand Up @@ -771,24 +771,17 @@ class Client:
self.message((f"Identify failed").encode())

def filter_handler() -> None:
if len(arguments) < 1:
if len(arguments) < 2:
self.reply_461(b"FILTER")
return
if not self.is_operator:
self.reply(b"481 %s :Permission denied" % (self.nickname))
self.message((f"Only operators can add filter patterns").encode())
return
self.server.add_filter(arguments[0].decode('utf-8'))

def unfilter_handler() -> None:
if len(arguments) < 1:
self.reply_461(b"UNFILTER")
return
if not self.is_operator:
self.reply(b"481 %s :Permission denied" % (self.nickname))
self.message((f"Only operators can remove filter patterns").encode())
return
self.server.remove_filter(arguments[0].decode('utf-8'))
if arguments[0].decode('utf-8').lower() == 'add':
self.server.add_filter(arguments[1].decode('utf-8'))
elif arguments[0].decode('utf-8').lower() == 'remove':
self.server.remove_filter(arguments[1].decode('utf-8'))

def notice_and_privmsg_handler() -> None:
if len(arguments) == 0:
Expand Down Expand Up @@ -1006,7 +999,6 @@ class Client:
b"REGISTER": register_handler,
b"SETPASSWORD": setpassword_handler,
b"TOPIC": topic_handler,
b"UNFILTER": unfilter_handler,
b"WALLOPS": wallops_handler,
b"WHO": who_handler,
b"WHOIS": whois_handler,
Expand Down

0 comments on commit 72f9966

Please sign in to comment.