forked from sch/KaikOut
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]
|
[list]
|
||||||
blacklist = """
|
blacklist = """
|
||||||
blacklist [+|-] <keyword>
|
blacklist [+|-] <jid>
|
||||||
Jabber IDs to blacklist
|
Jabber IDs to blacklist
|
||||||
comma-separated keywords
|
comma-separated keywords
|
||||||
'+' appends to, '-' removes from.
|
'+' appends to, '-' removes from.
|
||||||
"""
|
"""
|
||||||
whitelist = """
|
whitelist = """
|
||||||
whitelist [+|-] <keyword>
|
whitelist [+|-] <jid>
|
||||||
Jabber IDs to whitelist
|
Jabber IDs to whitelist
|
||||||
comma-separated keywords
|
comma-separated keywords
|
||||||
'+' appends to, '-' removes from.
|
'+' appends to, '-' removes from.
|
||||||
|
@ -175,7 +175,7 @@ Timer value (in seconds) for countdown before committing an action.
|
||||||
|
|
||||||
[rtbl]
|
[rtbl]
|
||||||
allow = """
|
allow = """
|
||||||
ignore [+|-] <keyword>
|
ignore [+|-] <jid>
|
||||||
Jabber IDs to ignore
|
Jabber IDs to ignore
|
||||||
comma-separated keywords
|
comma-separated keywords
|
||||||
'+' appends to, '-' removes from.
|
'+' appends to, '-' removes from.
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
__version__ = '0.0.3'
|
__version__ = '0.0.5'
|
||||||
__version_info__ = (0, 0, 3)
|
__version_info__ = (0, 0, 5)
|
||||||
|
|
|
@ -503,11 +503,14 @@ class XmppChat:
|
||||||
case _ if command_lowercase.startswith('scores reset'):
|
case _ if command_lowercase.startswith('scores reset'):
|
||||||
jid_bare = command[12:].strip()
|
jid_bare = command[12:].strip()
|
||||||
if jid_bare:
|
if jid_bare:
|
||||||
|
if jid_bare in self.settings[room]['scores']:
|
||||||
del self.settings[room]['scores'][jid_bare]
|
del self.settings[room]['scores'][jid_bare]
|
||||||
value = self.settings[room]['scores']
|
value = self.settings[room]['scores']
|
||||||
XmppCommands.update_setting_value(
|
XmppCommands.update_setting_value(
|
||||||
self, room, db_file, 'scores', value)
|
self, room, db_file, 'scores', value)
|
||||||
response = 'Score for {} has been reset'.format(jid_bare)
|
response = 'Score for {} has been reset'.format(jid_bare)
|
||||||
|
else:
|
||||||
|
response = 'Jabber ID {} is not known.'.format(jid_bare)
|
||||||
else:
|
else:
|
||||||
XmppCommands.update_setting_value(
|
XmppCommands.update_setting_value(
|
||||||
self, room, db_file, 'scores', {})
|
self, room, db_file, 'scores', {})
|
||||||
|
@ -515,7 +518,10 @@ class XmppChat:
|
||||||
case _ if command_lowercase.startswith('scores'):
|
case _ if command_lowercase.startswith('scores'):
|
||||||
jid_bare = command[6:].strip()
|
jid_bare = command[6:].strip()
|
||||||
if jid_bare:
|
if jid_bare:
|
||||||
|
if jid_bare in self.settings[room]['scores']:
|
||||||
response = str(self.settings[room]['scores'][jid_bare])
|
response = str(self.settings[room]['scores'][jid_bare])
|
||||||
|
else:
|
||||||
|
response = 'Jabber ID {} is not known.'.format(jid_bare)
|
||||||
else:
|
else:
|
||||||
response = str(self.settings[room]['scores'])
|
response = str(self.settings[room]['scores'])
|
||||||
case 'start':
|
case 'start':
|
||||||
|
|
|
@ -245,14 +245,13 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
db_file = Toml.instantiate(self, room)
|
db_file = Toml.instantiate(self, room)
|
||||||
if (XmppMuc.is_moderator(self, room, self.alias) and
|
if (XmppMuc.is_moderator(self, room, self.alias) and
|
||||||
self.settings[room]['enabled'] and
|
self.settings[room]['enabled'] and
|
||||||
alias != self.alias and
|
alias != self.alias):
|
||||||
jid_bare and
|
|
||||||
jid_bare not in self.settings[room]['jid_whitelist']):
|
|
||||||
timestamp = time.time()
|
timestamp = time.time()
|
||||||
fields = [alias, presence_body, identifier, timestamp]
|
fields = [alias, presence_body, identifier, timestamp]
|
||||||
Log.toml(self, room, fields, 'presence')
|
Log.toml(self, room, fields, 'presence')
|
||||||
# Count bans and kicks
|
# Count bans and kicks
|
||||||
await XmppObservation.observe_strikes(self, db_file, presence, room)
|
await XmppObservation.observe_strikes(self, db_file, presence, room)
|
||||||
|
if jid_bare and jid_bare not in self.settings[room]['jid_whitelist']:
|
||||||
# Check for status message
|
# Check for status message
|
||||||
await XmppObservation.observe_status_message(self, alias, db_file, jid_bare, presence_body, room)
|
await XmppObservation.observe_status_message(self, alias, db_file, jid_bare, presence_body, room)
|
||||||
# Check for inactivity
|
# Check for inactivity
|
||||||
|
|
|
@ -488,15 +488,15 @@ class XmppCommands:
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
def set_filter(self, room, db_file, keywords, filter, axis):
|
def set_filter(self, room, db_file, strings, filter, axis):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
db_file : str
|
db_file : str
|
||||||
Database filename.
|
Database filename.
|
||||||
keywords : str
|
strings : str
|
||||||
keyword (word or phrase).
|
string (word or phrase).
|
||||||
filter : str
|
filter : str
|
||||||
'allow' or 'deny'.
|
'allow' or 'deny'.
|
||||||
axis : boolean
|
axis : boolean
|
||||||
|
@ -507,27 +507,31 @@ class XmppCommands:
|
||||||
None.
|
None.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
keyword_list = self.settings[room][filter] if filter in self.settings[room] else []
|
string_list = self.settings[room][filter] if filter in self.settings[room] else []
|
||||||
new_keywords = keywords.split(',')
|
new_strings = strings.split(',')
|
||||||
processed_keywords = []
|
processed_strings = []
|
||||||
if axis:
|
if axis:
|
||||||
action = 'added'
|
action = 'added to'
|
||||||
for keyword in new_keywords:
|
for string in new_strings:
|
||||||
if keyword and keyword not in keyword_list:
|
if string and string not in string_list:
|
||||||
keyword_trim = keyword.strip()
|
string_trim = string.strip()
|
||||||
keyword_list.append(keyword_trim)
|
string_list.append(string_trim)
|
||||||
processed_keywords.append(keyword_trim)
|
processed_strings.append(string_trim)
|
||||||
else:
|
else:
|
||||||
action = 'removed'
|
action = 'removed from'
|
||||||
for keyword in new_keywords:
|
for string in new_strings:
|
||||||
if keyword and keyword in keyword_list:
|
if string and string in string_list:
|
||||||
keyword_trim = keyword.strip()
|
string_trim = string.strip()
|
||||||
keyword_list.remove(keyword_trim)
|
string_list.remove(string_trim)
|
||||||
processed_keywords.append(keyword_trim)
|
processed_strings.append(string_trim)
|
||||||
Toml.update_jid_settings(self, room, db_file, filter, keyword_list)
|
Toml.update_jid_settings(self, room, db_file, filter, string_list)
|
||||||
processed_keywords.sort()
|
processed_strings.sort()
|
||||||
message = 'Keywords "{}" have been {} to list "{}".'.format(
|
if processed_strings:
|
||||||
', '.join(processed_keywords), action, filter)
|
message = 'Strings "{}" have been {} list "{}".'.format(
|
||||||
|
', '.join(processed_strings), action, filter)
|
||||||
|
else:
|
||||||
|
message = 'Strings "{}" were already {} list "{}".'.format(
|
||||||
|
strings, action, filter)
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue