Skip to content

Commit

Permalink
Add RegEx ignores
Browse files Browse the repository at this point in the history
  • Loading branch information
luk3yx committed Mar 14, 2021
1 parent ec64370 commit 979aa96
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions config.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[core]
command_db = tempcmds.db
ignored = *!*@*/bot/*
regex_ignore = .*!.*@.*/bot/.*
prefix = $

reply_on_invalid = true
Expand Down
9 changes: 7 additions & 2 deletions lurklite/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
static_cmds = None

# The version
miniirc.version = f'lurklite v0.4.17 (powered by {miniirc.version})'
miniirc.version = f'lurklite v0.4.18 (powered by {miniirc.version})'

# Throw errors
class BotError(Exception):
Expand Down Expand Up @@ -51,7 +51,12 @@ def process_ignores(self, section):
res = set()
for victim in self.config[section].get('ignored', '').split(','):
victim = victim.strip()
res.add(re.escape(victim).lower().replace('\\*', '.*'))
if victim:
res.add(re.escape(victim).lower().replace('\\*', '.*'))

regex_ignore = self.config[section].get('regex_ignore', '').strip()
if regex_ignore:
res.add(regex_ignore)
return re.compile('^(' + ')|('.join(res) + ')$')

# Add extra items
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name = 'lurklite',
version = '0.4.17',
version = '0.4.18',
packages = ['lurklite'],
author = 'luk3yx',
description = 'A miniirc-based IRC bot.',
Expand Down

0 comments on commit 979aa96

Please sign in to comment.