Exemplo n.º 1
0
#--depends-on config

from src import ModuleManager, utils

DELAY = 30  # 30 seconds


@utils.export("channelset",
              utils.BoolSetting(
                  "slowvoice",
                  "Enable/disable giving +v to new users after a delay"))
@utils.export("channelset",
              utils.IntSetting("slowvoice-delay",
                               "Set delay for slowvoice in seconds"))
class Module(ModuleManager.BaseModule):
    @utils.hook("timer.slowvoice")
    def timer(self, event):
        event["channel"].send_mode("+v", [event["user"].nickname])

    @utils.hook("new.channel")
    def new_channel(self, event):
        event["channel"]._slowvoice_timers = {}

    @utils.hook("received.join")
    def on_join(self, event):
        if event["channel"].get_setting("slowvoice", False):
            delay = event["channel"].get_setting("slowvoice-delay", DELAY)
            timer = self.timers.add("slowvoice",
                                    delay,
                                    channel=event["channel"],
                                    user=event["user"])
Exemplo n.º 2
0
#--depends-on config
#--depends-on shorturl

import time
from src import ModuleManager, utils
import feedparser

RSS_INTERVAL = 60  # 1 minute


@utils.export("botset",
              utils.IntSetting("rss-interval",
                               "Interval (in seconds) between RSS polls",
                               example="120"))
@utils.export("channelset",
              utils.BoolSetting("rss-shorten",
                                "Whether or not to shorten RSS urls"))
class Module(ModuleManager.BaseModule):
    _name = "RSS"

    def on_load(self):
        self.timers.add("rss",
                        self.bot.get_setting("rss-interval", RSS_INTERVAL))

    def _format_entry(self, server, feed_title, entry, shorten):
        title = entry["title"]

        author = entry.get("author", None)
        author = " by %s" % author if author else ""

        link = entry.get("link", None)
Exemplo n.º 3
0
from src import ModuleManager, utils


class UserNotFoundException(Exception):
    pass


class InvalidTimeoutException(Exception):
    pass


@utils.export(
    "channelset",
    utils.IntSetting(
        "highlight-spam-threshold",
        "Set the number of nicknames in a message that qualifies as spam"))
@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",
Exemplo n.º 4
0
#--depends-on config

from src import ModuleManager, utils

DELAY = 5

rejoin_setting = utils.BoolSetting(
    "kick-rejoin", "Whether or not I should rejoin channels I get kicked from")
delay_setting = utils.IntSetting(
    "kick-rejoin-delay",
    "Amount of seconds to wait before rejoining a channel")


@utils.export("serverset", rejoin_setting)
@utils.export("serverset", delay_setting)
@utils.export("channelset", rejoin_setting)
@utils.export("channelset", delay_setting)
class Module(ModuleManager.BaseModule):
    def _should_rejoin(self, server, channel):
        return channel.get_setting("kick-rejoin",
                                   server.get_setting("kick-rejoin", False))

    def _get_delay(self, server, channel):
        return channel.get_setting(
            "kick-rejoin-delay", server.get_setting("kick-rejoin-delay",
                                                    DELAY))

    @utils.hook("self.kick")
    def on_kick(self, event):
        if self._should_rejoin(event["server"], event["channel"]):
            delay = self._get_delay(event["server"], event["channel"])
Exemplo n.º 5
0
#--depends-on channel_access
#--depends-on check_mode
#--depends-on commands
#--depends-on config

from src import ModuleManager, utils

class UserNotFoundException(Exception):
    pass
class InvalidTimeoutException(Exception):
    pass

@utils.export("channelset", utils.IntSetting("highlight-spam-threshold",
    "Set the number of nicknames in a message that qualifies as spam"))
@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:
Exemplo n.º 6
0
API_ISSUE_URL = "https://api.github.com/repos/%s/%s/issues/%s"
API_PULL_URL = "https://api.github.com/repos/%s/%s/pulls/%s"


@utils.export("channelset",
              utils.Setting(
                  "github-default-repo",
                  "Set the default github repo for the current channel",
                  example="jesopo/bitbot"))
@utils.export("channelset",
              utils.BoolSetting(
                  "auto-github",
                  "Enable/disable automatically getting github issue/PR info"))
@utils.export("channelset",
              utils.IntSetting(
                  "auto-github-cooldown",
                  "Set amount of seconds between auto-github duplicates",
                  example="300"))
class Module(ModuleManager.BaseModule):
    def _parse_ref(self, channel, ref):
        repo, _, number = ref.rpartition("#")
        org, _, repo = repo.partition("/")

        default_repo = channel.get_setting("github-default-repo", "")
        default_org, _, default_repo = default_repo.partition("/")

        if org and not repo:
            repo = org or default_repo
            org = default_org
        else:
            org = org or default_org
            repo = repo or default_repo
Exemplo n.º 7
0
import random, re, time
from src import EventManager, ModuleManager, utils

DUCK = "・゜゜・。。・゜゜\_o< QUACK!"
NO_DUCK = "There was no duck!"

DEFAULT_MIN_MESSAGES = 100


@utils.export("channelset",
              utils.BoolSetting("ducks-enabled",
                                "Whether or not to spawn ducks"))
@utils.export("channelset",
              utils.IntSetting("ducks-min-messages",
                               "Minimum messages between ducks spawning",
                               example="50"))
@utils.export(
    "channelset",
    utils.BoolSetting(
        "ducks-kick",
        "Whether or not to kick someone talking to non-existent ducks"))
class Module(ModuleManager.BaseModule):
    @utils.hook("new.channel")
    def new_channel(self, event):
        self.bootstrap_channel(event["channel"])

    def bootstrap_channel(self, channel):
        if not hasattr(channel, "duck_active"):
            channel.duck_active = None
            channel.duck_lines = 0