Merge branch 'master' of github.com:jesopo/bitbot

This commit is contained in:
Evelyn 2018-02-04 09:27:54 +00:00
commit 840fbcdb10
3 changed files with 18 additions and 10 deletions

View file

@ -291,7 +291,7 @@ def handle_PRIVMSG(data):
server = data.server server = data.server
nickname, username, hostname = Utils.seperate_hostmask(data.prefix) nickname, username, hostname = Utils.seperate_hostmask(data.prefix)
user = server.get_user(nickname) user = server.get_user(nickname)
message = data.args[1] message = "" if len(data.args) < 2 else data.args[1]
message_split = message.split(" ") message_split = message.split(" ")
target = data.args[0] target = data.args[0]
action = message.startswith("\01ACTION ") and message.endswith("\01") action = message.startswith("\01ACTION ") and message.endswith("\01")

View file

@ -44,10 +44,10 @@ class ModuleManager(object):
break break
import_name = "bitbot_%s" % name import_name = "bitbot_%s" % name
module = imp.load_source(import_name, filename) module = imp.load_source(import_name, filename)
assert hasattr(module, "Module" if not hasattr(module, "Module"):
), "module '%s' doesn't have a Module class." raise ImportError("module '%s' doesn't have a Module class.")
assert inspect.isclass(module.Module if not inspect.isclass(module.Module):
), "module '%s' has a Module attribute but it is not a class." raise ImportError("module '%s' has a Module attribute but it is not a class.")
module_object = module.Module(self.bot) module_object = module.Module(self.bot)
if not hasattr(module_object, "_name"): if not hasattr(module_object, "_name"):
module_object._name = name.title() module_object._name = name.title()

View file

@ -29,7 +29,11 @@ class Module(object):
validate=Utils.int_or_none) validate=Utils.int_or_none)
bot.events.on("postboot").on("configure").on( bot.events.on("postboot").on("configure").on(
"channelset").call(setting="highlight-spam-protection", "channelset").call(setting="highlight-spam-protection",
help="Enable/Disable highligh spam protection", help="Enable/Disable highlight spam protection",
validate=Utils.bool_or_none)
bot.events.on("postboot").on("configure").on(
"channelset").call(setting="highlight-spam-ban",
help="Enable/Disable banning highlight spammers instead of just kicking",
validate=Utils.bool_or_none) validate=Utils.bool_or_none)
def kick(self, event): def kick(self, event):
@ -85,7 +89,11 @@ class Module(object):
) + [event["server"].nickname] ) + [event["server"].nickname]
if len(set(nicknames) & set(event["message_split"])) >= event["channel"].get_setting( if len(set(nicknames) & set(event["message_split"])) >= event["channel"].get_setting(
"highlight-spam-threshold", 10): "highlight-spam-threshold", 10):
if event["channel"].get_setting("highlight-spam-protection", False): protection_enabled = event["channel"].get_setting("highlight-spam-protection", False)
if not event["channel"].mode_or_above(event["user"].nickname, "v"): has_mode = event["channel"].mode_or_above(event["user"].nickname, "v")
event["channel"].send_kick(event["user"].nickname, should_ban = event["channel"].get_setting("highlight-spam-ban", False)
"highlight spam detected") if protection_enabled and not has_mode:
if should_ban:
event["channel"].send_ban("*!%s@%s" % (event["user"].username,
event["user"].hostname))
event["channel"].send_kick(event["user"].nickname, "highlight spam detected")