Move all exports to @Utils.export calls
This commit is contained in:
parent
8b0314b190
commit
6eb8b1ba6d
15 changed files with 99 additions and 147 deletions
|
@ -1,11 +1,9 @@
|
|||
from src import Utils
|
||||
from src import ModuleManager, Utils
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, bot, events, exports):
|
||||
exports.add("serverset", {"setting": "accept-invites",
|
||||
@Utils.export("serverset", {"setting": "accept-invites",
|
||||
"help": "Set whether I accept invites on this server",
|
||||
"validate": Utils.bool_or_none})
|
||||
|
||||
class Module(ModuleManager.BaseModule):
|
||||
@Utils.hook("received.invite")
|
||||
def on_invite(self, event):
|
||||
if event["server"].is_own_nickname(event["target_user"].nickname):
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
from src import Utils
|
||||
from src import ModuleManager, Utils
|
||||
|
||||
class Module(object):
|
||||
@Utils.export("channelset", {"setting": "automode",
|
||||
"help": "Disable/Enable automode", "validate": Utils.bool_or_none})
|
||||
class Module(ModuleManager.BaseModule):
|
||||
_name = "AutoMode"
|
||||
def __init__(self, bot, events, exports):
|
||||
exports.add("channelset", {"setting": "automode",
|
||||
"help": "Disable/Enable automode",
|
||||
"validate": Utils.bool_or_none})
|
||||
|
||||
def _check_modes(self, channel, user):
|
||||
identified_account = user.get_identified_account()
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
from src import Utils
|
||||
from src import ModuleManager, Utils
|
||||
|
||||
class Module(object):
|
||||
_name = "Channel Op"
|
||||
def __init__(self, bot, events, exports):
|
||||
exports.add("channelset", {"setting": "highlight-spam-threshold",
|
||||
"help": "Set the number of nicknames in a message that "
|
||||
"qualifies as spam", "validate": Utils.int_or_none})
|
||||
exports.add("channelset", {"setting": "highlight-spam-protection",
|
||||
@Utils.export("channelset", {"setting": "highlight-spam-threshold",
|
||||
"help": "Set the number of nicknames in a message that qualifies as spam",
|
||||
"validate": Utils.int_or_none})
|
||||
@Utils.export("channelset", {"setting": "highlight-spam-protection",
|
||||
"help": "Enable/Disable highlight spam protection",
|
||||
"validate": Utils.bool_or_none})
|
||||
exports.add("channelset", {"setting": "highlight-spam-ban",
|
||||
@Utils.export("channelset", {"setting": "highlight-spam-ban",
|
||||
"help": "Enable/Disable banning highlight spammers "
|
||||
"instead of just kicking", "validate": Utils.bool_or_none})
|
||||
exports.add("channelset", {"setting": "ban-format",
|
||||
"help": "Set ban format ($n = nick, $u = username, "
|
||||
"$h = hostname)"})
|
||||
@Utils.export("channelset", {"setting": "ban-format",
|
||||
"help": "Set ban format ($n = nick, $u = username, $h = hostname)"})
|
||||
class Module(ModuleManager.BaseModule):
|
||||
_name = "Channel Op"
|
||||
|
||||
@Utils.hook("received.command.kick|k", channel_only=True,
|
||||
require_mode="o", usage="<nickname> [reason]", min_args=1)
|
||||
|
|
|
@ -1,25 +1,21 @@
|
|||
#--require-config virustotal-api-key
|
||||
|
||||
import re
|
||||
from src import Utils
|
||||
from src import ModuleManager, Utils
|
||||
|
||||
URL_VIRUSTOTAL = "https://www.virustotal.com/vtapi/v2/url/report"
|
||||
RE_URL = re.compile(r"https?://\S+", re.I)
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, bot, events, exports):
|
||||
self.bot = bot
|
||||
self.events = events
|
||||
exports.add("channelset", {"setting": "check-urls",
|
||||
"help": "Enable/Disable automatically checking for "
|
||||
"malicious URLs", "validate": Utils.bool_or_none})
|
||||
exports.add("serverset", {"setting": "check-urls",
|
||||
"help": "Enable/Disable automatically checking for "
|
||||
"malicious URLs", "validate": Utils.bool_or_none})
|
||||
exports.add("channelset", {"setting": "check-urls-kick",
|
||||
@Utils.export("channelset", {"setting": "check-urls",
|
||||
"help": "Enable/Disable automatically checking for malicious URLs",
|
||||
"validate": Utils.bool_or_none})
|
||||
@Utils.export("serverset", {"setting": "check-urls",
|
||||
"help": "Enable/Disable automatically checking for malicious URLs",
|
||||
"validate": Utils.bool_or_none})
|
||||
@Utils.export("channelset", {"setting": "check-urls-kick",
|
||||
"help": "Enable/Disable automatically kicking users that "
|
||||
"send malicious URLs", "validate": Utils.bool_or_none})
|
||||
|
||||
class Module(ModuleManager.BaseModule):
|
||||
@Utils.hook("received.message.channel")
|
||||
def message(self, event):
|
||||
match = RE_URL.search(event["message"])
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import re
|
||||
from src import EventManager, Utils
|
||||
from src import EventManager, ModuleManager, Utils
|
||||
|
||||
STR_MORE = "%s (more...)" % Utils.FONT_RESET
|
||||
STR_CONTINUED = "(...continued) "
|
||||
|
@ -43,17 +43,13 @@ class StdErr(Out):
|
|||
def prefix(self):
|
||||
return Utils.color(Utils.bold(self.module_name), Utils.COLOR_RED)
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, bot, events, exports):
|
||||
self.events = events
|
||||
|
||||
exports.add("channelset", {"setting": "command-prefix",
|
||||
@Utils.export("channelset", {"setting": "command-prefix",
|
||||
"help": "Set the command prefix used in this channel"})
|
||||
exports.add("serverset", {"setting": "command-prefix",
|
||||
@Utils.export("serverset", {"setting": "command-prefix",
|
||||
"help": "Set the command prefix used on this server"})
|
||||
exports.add("serverset", {"setting": "identity-mechanism",
|
||||
@Utils.export("serverset", {"setting": "identity-mechanism",
|
||||
"help": "Set the identity mechanism for this server"})
|
||||
|
||||
class Module(ModuleManager.BaseModule):
|
||||
@Utils.hook("new.user|channel")
|
||||
def new(self, event):
|
||||
if "user" in event:
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
import datetime
|
||||
from src import Utils
|
||||
from src import ModuleManager, Utils
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, bot, events, exports):
|
||||
self.bot = bot
|
||||
exports.add("serverset", {"setting": "ctcp-responses",
|
||||
@Utils.export("serverset", {"setting": "ctcp-responses",
|
||||
"help": "Set whether I respond to CTCPs on this server",
|
||||
"validate": Utils.bool_or_none})
|
||||
|
||||
class Module(ModuleManager.BaseModule):
|
||||
@Utils.hook("received.message.private")
|
||||
def private_message(self, event):
|
||||
if event["message"][0] == "\x01" and event["message"][-1] == "\x01":
|
||||
|
|
|
@ -13,24 +13,20 @@ DUCK_MESSAGE_RARE = ["beep boop!", "QUACK QUACK QUACK QUACK QUACK!!", "HONK!",
|
|||
DUCK_MINIMUM_MESSAGES = 10
|
||||
DUCK_MINIMUM_UNIQUE = 3
|
||||
|
||||
|
||||
@Utils.export("channelset", {"setting": "ducks-enabled",
|
||||
"help": "Toggle ducks!", "validate": Utils.bool_or_none})
|
||||
@Utils.export("channelset", {"setting": "ducks-kick",
|
||||
"help": "Should the bot kick if there's no duck?",
|
||||
"validate": Utils.bool_or_none})
|
||||
@Utils.export("channelset", {"setting": "ducks-min-unique",
|
||||
"help": "Minimum unique users required to talk before a duck spawns.",
|
||||
"validate": Utils.int_or_none})
|
||||
@Utils.export("channelset", {"setting": "ducks-min-messages",
|
||||
"help": "Minimum messages between ducks spawning.",
|
||||
"validate": Utils.int_or_none})
|
||||
class Module(object):
|
||||
def __init__(self, bot, events, exports):
|
||||
self.bot = bot
|
||||
exports.add("channelset", {"setting": "ducks-enabled",
|
||||
"help": "Toggle ducks!", "validate": Utils.bool_or_none})
|
||||
|
||||
exports.add("channelset", {"setting": "ducks-kick",
|
||||
"help": "Should the bot kick if there's no duck?",
|
||||
"validate": Utils.bool_or_none})
|
||||
|
||||
exports.add("channelset", {"setting": "ducks-min-unique",
|
||||
"help": "Minimum unique users required to talk before a "
|
||||
"duck spawns.", "validate": Utils.int_or_none})
|
||||
|
||||
exports.add("channelset", {"setting": "ducks-min-messages",
|
||||
"help": "Minimum messages between ducks spawning.",
|
||||
"validate": Utils.int_or_none})
|
||||
|
||||
for server in self.bot.servers.values():
|
||||
for channel in server.channels.values():
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
from src import Utils
|
||||
from src import ModuleManager, Utils
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, bot, events, exports):
|
||||
exports.add("channelset", {"setting": "greeting",
|
||||
@Utils.export("channelset", {"setting": "greeting",
|
||||
"help": "Set a greeting to send to users when they join"})
|
||||
|
||||
class Module(ModuleManager.BaseModule):
|
||||
@Utils.hook("received.join")
|
||||
def join(self, event):
|
||||
greeting = event["channel"].get_setting("greeting", None)
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
import re, time
|
||||
from src import EventManager, Utils
|
||||
from src import EventManager, ModuleManager, Utils
|
||||
|
||||
REGEX_KARMA = re.compile("^(.*[^-+])[-+]*(\+{2,}|\-{2,})$")
|
||||
KARMA_DELAY_SECONDS = 3
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, bot, events, exports):
|
||||
self.events = events
|
||||
exports.add("channelset", {"setting": "karma-verbose",
|
||||
"help": "Disable/Enable automatically responding to "
|
||||
"karma changes", "validate": Utils.bool_or_none})
|
||||
|
||||
@Utils.export("channelset", {"setting": "karma-verbose",
|
||||
"help": "Disable/Enable automatically responding to karma changes",
|
||||
"validate": Utils.bool_or_none})
|
||||
class Module(ModuleManager.BaseModule):
|
||||
@Utils.hook("new.user")
|
||||
def new_user(self, event):
|
||||
event["user"].last_karma = None
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
#--require-config lastfm-api-key
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from src import Utils
|
||||
from src import ModuleManager, Utils
|
||||
|
||||
URL_SCROBBLER = "http://ws.audioscrobbler.com/2.0/"
|
||||
|
||||
class Module(object):
|
||||
@Utils.export("set", {"setting": "lastfm", "help": "Set last.fm username"})
|
||||
class Module(ModuleManager.BaseModule):
|
||||
_name = "last.fm"
|
||||
def __init__(self, bot, events, exports):
|
||||
self.bot = bot
|
||||
self.events = events
|
||||
|
||||
exports.add("set", {"setting": "lastfm",
|
||||
"help": "Set username on last.fm"})
|
||||
|
||||
@Utils.hook("received.command.np|listening|nowplaying", usage="[username]")
|
||||
def np(self, event):
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import base64
|
||||
from src import EventManager, Utils
|
||||
from src import EventManager, ModuleManager, Utils
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, bot, events, exports):
|
||||
exports.add("serverset", {"setting": "nickserv-password",
|
||||
@Utils.export("serverset", {"setting": "nickserv-password",
|
||||
"help": "Set the nickserv password for this server"})
|
||||
|
||||
class Module(ModuleManager.BaseModule):
|
||||
@Utils.hook("received.numeric.001", priority=EventManager.PRIORITY_URGENT)
|
||||
def on_connect(self, event):
|
||||
nickserv_password = event["server"].get_setting(
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
import base64
|
||||
from src import Utils
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, bot, events, exports):
|
||||
exports.add("serverset", {"setting": "sasl",
|
||||
"help": "Set the sasl username/password for this server",
|
||||
"validate": self._validate})
|
||||
from src import ModuleManager, Utils
|
||||
|
||||
def _validate(self, s):
|
||||
mechanism = s
|
||||
|
@ -13,6 +7,10 @@ class Module(object):
|
|||
mechanism, arguments = s.split(" ", 1)
|
||||
return {"mechanism": mechanism, "args": arguments}
|
||||
|
||||
@Utils.export("serverset", {"setting": "sasl",
|
||||
"help": "Set the sasl username/password for this server",
|
||||
"validate": _validate})
|
||||
class Module(ModuleManager.BaseModule):
|
||||
@Utils.hook("received.cap.ls")
|
||||
def on_cap(self, event):
|
||||
has_sasl = "sasl" in event["capabilities"]
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
import re, traceback
|
||||
from src import Utils
|
||||
from src import ModuleManager, Utils
|
||||
|
||||
REGEX_SPLIT = re.compile("(?<!\\\\)/")
|
||||
REGEX_SED = re.compile("^s/")
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, bot, events, exports):
|
||||
self.events = events
|
||||
|
||||
exports.add("channelset", {"setting": "sed",
|
||||
@Utils.export("channelset", {"setting": "sed",
|
||||
"help": "Disable/Enable sed in a channel",
|
||||
"validate": Utils.bool_or_none})
|
||||
exports.add("channelset", {"setting": "sed-sender-only",
|
||||
"help": "Disable/Enable sed only looking at the messages "
|
||||
"sent by the user", "validate": Utils.bool_or_none})
|
||||
|
||||
@Utils.export("channelset", {"setting": "sed-sender-only",
|
||||
"help": "Disable/Enable sed only looking at the messages sent by the user",
|
||||
"validate": Utils.bool_or_none})
|
||||
class Module(ModuleManager.BaseModule):
|
||||
@Utils.hook("received.message.channel")
|
||||
def channel_message(self, event):
|
||||
sed_split = re.split(REGEX_SPLIT, event["message"], 3)
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
#--require-config trakt-api-key
|
||||
|
||||
from src import Utils
|
||||
from src import ModuleManager, Utils
|
||||
|
||||
URL_TRAKT = "https://api-v2launch.trakt.tv/users/%s/watching"
|
||||
URL_TRAKTSLUG = "https://trakt.tv/%s/%s"
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, bot, events, exports):
|
||||
self.bot = bot
|
||||
exports.add("set", {"setting": "trakt",
|
||||
"help": "Set username on trakt.tv"})
|
||||
|
||||
@Utils.export("set", {"setting": "trakt", "help": "Set username on trakt.tv"})
|
||||
class Module(ModuleManager.BaseModule):
|
||||
@Utils.hook("received.command.nowwatching|nw", usage="[username]")
|
||||
def now_watching(self, event):
|
||||
"""
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#--require-config google-api-key
|
||||
|
||||
import re
|
||||
from src import Utils
|
||||
from src import ModuleManager, Utils
|
||||
|
||||
REGEX_YOUTUBE = re.compile(
|
||||
"https?://(?:www.)?(?:youtu.be/|youtube.com/watch\?[\S]*v=)([\w\-]{11})",
|
||||
|
@ -16,15 +16,10 @@ URL_YOUTUBESHORT = "https://youtu.be/%s"
|
|||
ARROW_UP = "▲"
|
||||
ARROW_DOWN = "▼"
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, bot, events, exports):
|
||||
self.bot = bot
|
||||
self.events = events
|
||||
|
||||
exports.add("channelset", {"setting": "auto-youtube",
|
||||
"help": "Disable/Enable automatically getting info from "
|
||||
"youtube URLs", "validate": Utils.bool_or_none})
|
||||
|
||||
@Utils.export("channelset", {"setting": "auto-youtube",
|
||||
"help": "Disable/Enable automatically getting info from youtube URLs",
|
||||
"validate": Utils.bool_or_none})
|
||||
class Module(ModuleManager.BaseModule):
|
||||
def get_video_page(self, video_id, part):
|
||||
return Utils.get_url(URL_YOUTUBEVIDEO, get_params={"part": part,
|
||||
"id": video_id, "key": self.bot.config["google-api-key"]},
|
||||
|
|
Loading…
Reference in a new issue