Exemplo n.º 1
0
    def userKicked(self, kickee, channel, kicker, message):
        """Triggered when a user gets kicked"""
        # kick message
        if self.config["Actions"]:
            msg = self.config["Actions"].get("userKicked",
                                             "").replace("$KICKER", kicker)
            msg = msg.replace("$KICKEE", kickee).replace("$CHANNEL", channel)
            msg = formatting.from_human_readable(msg)
            if msg:
                self.msg(channel, msg)

        self.log.info(
            "{kickee} was kicked from {channel} by {kicker} "
            "({reason})",
            kickee=kickee,
            channel=channel,
            kicker=kicker,
            reason=message)
        channel = channel.lower()
        self.remove_user_from_cache(kickee)
        self.userlist[channel].remove(kickee)

        if channel in self.channelwatchers:
            for watcher in self.channelwatchers[channel]:
                watcher.kick(kickee, kicker, message)
Exemplo n.º 2
0
 def irc_notice(self, data):
     """Send a notice to an IRC channel or user
     Usage: notice <channel> <message>"""
     if not data:
         raise ValueError("No channel and message given")
     channel, message = data.split(None, 1)
     self.bot.notice(channel, formatting.from_human_readable(message))
Exemplo n.º 3
0
def simple_trigger(bot):
    """Send a user defined reply to IRC when the corresponding trigger is mentioned
    """
    while True:
        command, sender, senderhost, channel = yield
        answer = command["answer"]
        if isinstance(answer, list):
            answer = random.choice(answer)
        msg = answer.replace("$USER", sender).replace("$CHANNEL", channel)

        # Replace colors
        msg = formatting.from_human_readable(msg)
        bot.msg(channel, msg)
Exemplo n.º 4
0
 def __init__(self, bot, channel, config):
     super(Greeter, self).__init__(bot, channel, config)
     # pattern so only certain new users get greeted
     # useful to only greet webchat user
     self.patterns = config.get("patterns", ["*"])
     if isinstance(self.patterns, str):
         self.log.warn("'patterns' should be a list, not a single string")
         self.patterns = [self.patterns]
     # nicks that many users are likely to use
     self.standard_nicks = set(map(lambda x: x.lower(),
                                   config.get("standard_nicks", [])))
     self.message = formatting.from_human_readable(
         config.get("message", "Welcome, $USER"))
     # read list of previously greeted users from disk
     self.already_greeted = self.load_greeted_file()
Exemplo n.º 5
0
 def __init__(self, bot, channel, config):
     super(Greeter, self).__init__(bot, channel, config)
     # pattern so only certain new users get greeted
     # useful to only greet webchat user
     self.patterns = config.get("patterns", ["*"])
     if isinstance(self.patterns, str):
         self.log.warn("'patterns' should be a list, not a single string")
         self.patterns = [self.patterns]
     # nicks that many users are likely to use
     self.standard_nicks = set(
         map(lambda x: x.lower(), config.get("standard_nicks", [])))
     self.message = formatting.from_human_readable(
         config.get("message", "Welcome, $USER"))
     # read list of previously greeted users from disk
     self.already_greeted = self.load_greeted_file()
Exemplo n.º 6
0
    def kickedFrom(self, channel, kicker, message):
        """Triggered when bot gets kicked"""
        channel = channel.lower()
        self.log.warn("Kicked from {channel} by {kicker} ({reason})",
                      channel=channel,
                      kicker=kicker,
                      reason=message)
        if self.config["Connection"].get("rejoinKicked", False):
            self.join(channel)
            if self.config["Actions"]:
                msg = self.config["Actions"].get("kickedFrom", "").replace(
                    "$KICKER", kicker)
                msg = msg.replace("$CHANNEL",
                                  channel).replace("$MESSAGE", message)
                msg = formatting.from_human_readable(msg)
                if msg:
                    self.msg(channel, msg)

        self.userlist.pop(channel)
        if channel in self.channelwatchers:
            for watcher in self.channelwatchers[channel]:
                watcher.kick(self.nickname, kicker, message)