Ejemplo n.º 1
0
 def on_load(self):
     setting = utils.OptionsSetting(
         [],
         "url-shortener",
         "Set URL shortener service",
         options_factory=self._shorturl_options_factory)
     self.exports.add("channelset", setting)
     self.exports.add("serverset", setting)
     self.exports.add("botset", setting)
Ejemplo n.º 2
0
    def on_load(self):
        self.exports.add("shorturl", self._shorturl)
        self.exports.add("shorturl-any", self._shorturl_any)

        self.exports.add("shorturl-s-bitly", self._bitly)

        setting = utils.OptionsSetting(
            "url-shortener", [],
            "Set URL shortener service",
            options_factory=self._shorturl_options_factory)
        self.exports.add("serverset", setting)
        self.exports.add("botset", setting)
Ejemplo n.º 3
0
@utils.export("channelset",
              utils.BoolSetting("highlight-spam-protection",
                                "Enable/Disable highlight spam protection"))
@utils.export(
    "channelset",
    utils.BoolSetting(
        "highlight-spam-ban",
        "Enable/Disable banning highlight spammers instead of just kicking"))
@utils.export("channelset",
              utils.Setting(
                  "ban-format",
                  "Set ban format ($n = nick, $u = username, $h = hostname)",
                  example="*!$u@$h"))
@utils.export("serverset",
              utils.OptionsSetting("mute-method",
                                   ["qmode", "insp", "unreal", "none"],
                                   "Set this server's method of muting users"))
class Module(ModuleManager.BaseModule):
    _name = "ChanOp"

    @utils.hook("timer.unban")
    def _timer_unban(self, event):
        server = self.bot.get_server_by_id(event["server_id"])
        if server and event["channel_name"] in server.channels:
            channel = server.channels.get(event["channel_name"])
            channel.send_unban(event["hostmask"])

    def _kick(self, server, channel, nickname, reason):
        target_user = server.get_user(nickname)
        if channel.has_user(target_user):
            channel.send_kick(nickname, reason)
Ejemplo n.º 4
0
COMMAND_METHODS = ["PRIVMSG", "NOTICE"]

REGEX_ARG_NUMBER = re.compile(r"\$(?:(\d+)(-?)|(-))")

MESSAGE_TAGS_CAP = utils.irc.Capability("message-tags",
    "draft/message-tags-0.2")
MSGID_TAG = utils.irc.MessageTag("msgid", "draft/msgid")

NON_ALPHANUMERIC = [char for char in string.printable if not char.isalnum()]

class BadContextException(Exception):
    def __init__(self, required_context):
        self.required_context = required_context
        Exception.__init__(self)

SETTING_COMMANDMETHOD = utils.OptionsSetting(COMMAND_METHODS, COMMAND_METHOD,
    "Set the method used to respond to commands")

@utils.export("channelset", utils.Setting("command-prefix",
    "Set the command prefix used in this channel", example="!"))
@utils.export("serverset", utils.Setting("command-prefix",
    "Set the command prefix used on this server", example="!"))
@utils.export("serverset", SETTING_COMMANDMETHOD)
@utils.export("channelset", SETTING_COMMANDMETHOD)
@utils.export("botset", SETTING_COMMANDMETHOD)
@utils.export("channelset", utils.BoolSetting("hide-prefix",
    "Disable/enable hiding prefix in command reponses"))
@utils.export("channelset", utils.BoolSetting("commands",
    "Disable/enable responding to commands in-channel"))
@utils.export("channelset", utils.BoolSetting("prefixed-commands",
    "Disable/enable responding to prefixed commands in-channel"))
class Module(ModuleManager.BaseModule):
Ejemplo n.º 5
0
                                    example="have a nice trip")

BAN_FORMATTING = "${n} = nick, ${u} = username, ${h} = hostname, ${a} = account"


@utils.export("channelset",
              utils.Setting("ban-format",
                            "Set ban format (%s)" % BAN_FORMATTING,
                            example="*!${u}@${h}"))
@utils.export("channelset",
              utils.Setting("ban-format-account",
                            "Set ban format for users with accounts (%s)" %
                            BAN_FORMATTING,
                            example="~a:${a}"))
@utils.export("serverset",
              utils.OptionsSetting(list(QUIET_METHODS.keys()), "quiet-method",
                                   "Set this server's method of muting users"))
@utils.export("serverset",
              utils.OptionsSetting(
                  list(ABAN_METHODS.keys()), "aban-method",
                  "Set this server's method of banning users by account"))
@utils.export("botset", KICK_REASON_SETTING)
@utils.export("serverset", KICK_REASON_SETTING)
@utils.export("channelset", KICK_REASON_SETTING)
class Module(ModuleManager.BaseModule):
    _name = "ChanOp"

    @utils.hook("timer.unmode")
    def unmode(self, timer):
        channel = self.bot.database.channels.by_id(timer.kwargs["channel"])

        if channel:
Ejemplo n.º 6
0
#--depends-on commands
#--depends-on config

import base64, binascii, os
import scrypt
from src import ModuleManager, utils

REQUIRES_IDENTIFY = "You need to be identified to use that command"
REQUIRES_IDENTIFY_INTERNAL = ("You need to be identified to use that command "
                              "(/msg %s register | /msg %s identify)")


@utils.export(
    "serverset",
    utils.OptionsSetting(["internal", "ircv3-account"], "identity-mechanism",
                         "Set the identity mechanism for this server"))
class Module(ModuleManager.BaseModule):
    @utils.hook("new.user")
    def new_user(self, event):
        self._logout(event["user"])
        event["user"].admin_master = False

    def _master_password(self):
        master_password = self._random_password()
        hash, salt = self._make_hash(master_password)
        self.bot.set_setting("master-password", [hash, salt])
        return master_password

    def command_line(self, args: str):
        if args == "master-password":
            master_password = self._master_password()