diff --git a/README.md b/README.md index 81d7685..ae70136 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,10 @@ If you want the server to load a file (*module*) on startup, add it to the `modu > Adds `/getmotd` & `/setmotd` to update the motd on the fly (no reboot). +* `abot.py` + + > AnswerBot. Hides stupid questions from chat and tells the sender about `/faq` or the like + # Code styleguide & tips diff --git a/abot.py b/abot.py new file mode 100644 index 0000000..3d8af58 --- /dev/null +++ b/abot.py @@ -0,0 +1,25 @@ +from helpers import * +from re import compile as reg_compile + +rank_regex = "visitor|member|builder|trusted|helper|mod|admin" + +faq_regex = [ + # Asking for ranks or WE + "how.+ (get|be(come)?|).+ (%s|WorldEdit|WE|W.E.)" % rank_regex, + # Asking why p clear won't work + "why.+ can.+( /?p clear| clear.+plot)" +] + +faq_regex = [reg_compile(reg) for reg in faq_regex] + +@hook.event("player.AsyncPlayerChatEvent", "low") +def onChat(event): + sender = event.getPlayer() + message = event.getMessage().lower() + for regex in faq_regex: + if regex.search(message): + plugHeader(sender, "AnswerBot") + msg(sender, "&aIt looks like you aksed a question that is likely answered in our FAQ.") + msg(sender, "&aPlease take a look at the &4&l/faq&a command and read through the pages.") + event.setCancelled(True) + break \ No newline at end of file diff --git a/main.py b/main.py index fe6caad..1a4eba2 100644 --- a/main.py +++ b/main.py @@ -30,8 +30,21 @@ def onDisable(): log("Loading RedstonerUtils...") -# Import all modules -modules = ["misc", "adminchat", "lagchunks", "reports", "chatgroups", "webtoken", "saylol", "skullclick", "mentio", "cycle", "motd"] +# Import all modules, in this order +modules = [ + "misc", + "adminchat", + "lagchunks", + "reports", + "chatgroups", + "webtoken", + "saylol", + "skullclick", + "mentio", + "cycle", + "motd", + "abot" +] mod = {} for module in modules: try: