示例#1
0
文件: irc.py 项目: SandyWalsh/pyhole
    def reply(self, msg):
        """Send a privmsg"""
        if not hasattr(msg, "encode"):
            try:
                msg = str(msg)
            except Exception:
                self.log.error("msg cannot be converted to string")
                return

        msg = msg.encode("utf-8").split("\n")
        # 10 is completely arbitrary for now
        if len(msg) > 10:
            msg = msg[0:8]
            msg.append("...")

        for line in msg:
            if self.addressed:
                source = self.source.split("!")[0]
                self.connection.privmsg(self.target, "%s: %s" % (source, line))
                self.log.info("-%s- <%s> %s: %s" % (self.target, self.nick,
                        source, line))
            else:
                self.connection.privmsg(self.target, line)
                if irclib.is_channel(self.target):
                    self.log.info("-%s- <%s> %s" % (self.target, self.nick,
                            line))
                else:
                    self.log.info("<%s> %s" % (self.nick, line))
示例#2
0
文件: irc.py 项目: comstud/pyhole
 def on_welcome(self, connection, event):
     """Join channels upon successful connection"""
     for channel in self.channels:
         c = channel.split(" ", 1)
         if irclib.is_channel(c[0]):
             self.log.info("Joining %s" % c[0])
             if len(c) > 1:
                 connection.join(c[0], c[1])
             else:
                 connection.join(c[0])
示例#3
0
文件: irc.py 项目: comstud/pyhole
 def join_channel(self, params):
     """Join a channel"""
     channel = params.split(" ", 1)
     self.reply("Joining %s" % channel[0])
     if irclib.is_channel(channel[0]):
         self.channels.append(channel[0])
         if len(channel) > 1:
             self.connection.join(channel[0], channel[1])
         else:
             self.connection.join(channel[0])
示例#4
0
文件: irc.py 项目: SandyWalsh/pyhole
    def on_welcome(self, connection, event):
        """Join channels upon successful connection"""
        if self.identify_password:
            self.privmsg("NickServ", "IDENTIFY %s" % self.identify_password)

        for channel in self.channels:
            c = channel.split(" ", 1)
            if irclib.is_channel(c[0]):
                if len(c) > 1:
                    connection.join(c[0], c[1])
                else:
                    connection.join(c[0])