Exclude moderation abuse check from whitelist check;
Fix command scores upon a unknown JID (Thank you. mirux.); Correct language for keyword handling.
This commit is contained in:
parent
7f8adb501b
commit
7ca023011a
5 changed files with 49 additions and 40 deletions
|
@ -53,13 +53,13 @@ Leave groupchat and delete it from bookmarks.
|
|||
|
||||
[list]
|
||||
blacklist = """
|
||||
blacklist [+|-] <keyword>
|
||||
blacklist [+|-] <jid>
|
||||
Jabber IDs to blacklist
|
||||
comma-separated keywords
|
||||
'+' appends to, '-' removes from.
|
||||
"""
|
||||
whitelist = """
|
||||
whitelist [+|-] <keyword>
|
||||
whitelist [+|-] <jid>
|
||||
Jabber IDs to whitelist
|
||||
comma-separated keywords
|
||||
'+' appends to, '-' removes from.
|
||||
|
@ -175,7 +175,7 @@ Timer value (in seconds) for countdown before committing an action.
|
|||
|
||||
[rtbl]
|
||||
allow = """
|
||||
ignore [+|-] <keyword>
|
||||
ignore [+|-] <jid>
|
||||
Jabber IDs to ignore
|
||||
comma-separated keywords
|
||||
'+' appends to, '-' removes from.
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
__version__ = '0.0.3'
|
||||
__version_info__ = (0, 0, 3)
|
||||
__version__ = '0.0.5'
|
||||
__version_info__ = (0, 0, 5)
|
||||
|
|
|
@ -503,11 +503,14 @@ class XmppChat:
|
|||
case _ if command_lowercase.startswith('scores reset'):
|
||||
jid_bare = command[12:].strip()
|
||||
if jid_bare:
|
||||
del self.settings[room]['scores'][jid_bare]
|
||||
value = self.settings[room]['scores']
|
||||
XmppCommands.update_setting_value(
|
||||
self, room, db_file, 'scores', value)
|
||||
response = 'Score for {} has been reset'.format(jid_bare)
|
||||
if jid_bare in self.settings[room]['scores']:
|
||||
del self.settings[room]['scores'][jid_bare]
|
||||
value = self.settings[room]['scores']
|
||||
XmppCommands.update_setting_value(
|
||||
self, room, db_file, 'scores', value)
|
||||
response = 'Score for {} has been reset'.format(jid_bare)
|
||||
else:
|
||||
response = 'Jabber ID {} is not known.'.format(jid_bare)
|
||||
else:
|
||||
XmppCommands.update_setting_value(
|
||||
self, room, db_file, 'scores', {})
|
||||
|
@ -515,7 +518,10 @@ class XmppChat:
|
|||
case _ if command_lowercase.startswith('scores'):
|
||||
jid_bare = command[6:].strip()
|
||||
if jid_bare:
|
||||
response = str(self.settings[room]['scores'][jid_bare])
|
||||
if jid_bare in self.settings[room]['scores']:
|
||||
response = str(self.settings[room]['scores'][jid_bare])
|
||||
else:
|
||||
response = 'Jabber ID {} is not known.'.format(jid_bare)
|
||||
else:
|
||||
response = str(self.settings[room]['scores'])
|
||||
case 'start':
|
||||
|
|
|
@ -245,18 +245,17 @@ class XmppClient(slixmpp.ClientXMPP):
|
|||
db_file = Toml.instantiate(self, room)
|
||||
if (XmppMuc.is_moderator(self, room, self.alias) and
|
||||
self.settings[room]['enabled'] and
|
||||
alias != self.alias and
|
||||
jid_bare and
|
||||
jid_bare not in self.settings[room]['jid_whitelist']):
|
||||
alias != self.alias):
|
||||
timestamp = time.time()
|
||||
fields = [alias, presence_body, identifier, timestamp]
|
||||
Log.toml(self, room, fields, 'presence')
|
||||
# Count bans and kicks
|
||||
await XmppObservation.observe_strikes(self, db_file, presence, room)
|
||||
# Check for status message
|
||||
await XmppObservation.observe_status_message(self, alias, db_file, jid_bare, presence_body, room)
|
||||
# Check for inactivity
|
||||
await XmppObservation.observe_inactivity(self, db_file, room)
|
||||
if jid_bare and jid_bare not in self.settings[room]['jid_whitelist']:
|
||||
# Check for status message
|
||||
await XmppObservation.observe_status_message(self, alias, db_file, jid_bare, presence_body, room)
|
||||
# Check for inactivity
|
||||
await XmppObservation.observe_inactivity(self, db_file, room)
|
||||
|
||||
|
||||
def on_muc_self_presence(self, presence):
|
||||
|
|
|
@ -488,15 +488,15 @@ class XmppCommands:
|
|||
return message
|
||||
|
||||
|
||||
def set_filter(self, room, db_file, keywords, filter, axis):
|
||||
def set_filter(self, room, db_file, strings, filter, axis):
|
||||
"""
|
||||
|
||||
Parameters
|
||||
----------
|
||||
db_file : str
|
||||
Database filename.
|
||||
keywords : str
|
||||
keyword (word or phrase).
|
||||
strings : str
|
||||
string (word or phrase).
|
||||
filter : str
|
||||
'allow' or 'deny'.
|
||||
axis : boolean
|
||||
|
@ -507,27 +507,31 @@ class XmppCommands:
|
|||
None.
|
||||
|
||||
"""
|
||||
keyword_list = self.settings[room][filter] if filter in self.settings[room] else []
|
||||
new_keywords = keywords.split(',')
|
||||
processed_keywords = []
|
||||
string_list = self.settings[room][filter] if filter in self.settings[room] else []
|
||||
new_strings = strings.split(',')
|
||||
processed_strings = []
|
||||
if axis:
|
||||
action = 'added'
|
||||
for keyword in new_keywords:
|
||||
if keyword and keyword not in keyword_list:
|
||||
keyword_trim = keyword.strip()
|
||||
keyword_list.append(keyword_trim)
|
||||
processed_keywords.append(keyword_trim)
|
||||
action = 'added to'
|
||||
for string in new_strings:
|
||||
if string and string not in string_list:
|
||||
string_trim = string.strip()
|
||||
string_list.append(string_trim)
|
||||
processed_strings.append(string_trim)
|
||||
else:
|
||||
action = 'removed'
|
||||
for keyword in new_keywords:
|
||||
if keyword and keyword in keyword_list:
|
||||
keyword_trim = keyword.strip()
|
||||
keyword_list.remove(keyword_trim)
|
||||
processed_keywords.append(keyword_trim)
|
||||
Toml.update_jid_settings(self, room, db_file, filter, keyword_list)
|
||||
processed_keywords.sort()
|
||||
message = 'Keywords "{}" have been {} to list "{}".'.format(
|
||||
', '.join(processed_keywords), action, filter)
|
||||
action = 'removed from'
|
||||
for string in new_strings:
|
||||
if string and string in string_list:
|
||||
string_trim = string.strip()
|
||||
string_list.remove(string_trim)
|
||||
processed_strings.append(string_trim)
|
||||
Toml.update_jid_settings(self, room, db_file, filter, string_list)
|
||||
processed_strings.sort()
|
||||
if processed_strings:
|
||||
message = 'Strings "{}" have been {} list "{}".'.format(
|
||||
', '.join(processed_strings), action, filter)
|
||||
else:
|
||||
message = 'Strings "{}" were already {} list "{}".'.format(
|
||||
strings, action, filter)
|
||||
return message
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue