Exemple #1
0
 def sendNotice(self, text, handle):
     h = unicode(handle)
     t = unicode(text)
     try:
         helpers.notice(self.cli, h, t)
     except socket.error:
         self.setConnectionBroken()
Exemple #2
0
 def sendNotice(self, text, handle):
     h = str(handle)
     t = str(text)
     try:
         helpers.notice(self.cli, h, t)
     except socket.error:
         self.setConnectionBroken()
Exemple #3
0
 def privmsg(self, nick, chan, msg):
     try:
         msg = msg.decode('utf-8')
     except UnicodeDecodeError:
         msg = msg.decode('iso-8859-1', 'ignore')
     # display msg, do other stuff
     if len(msg) == 0:
         return
     # silently ignore CTCP
     if msg[0] == '\x01':
         handle = nick[0:nick.find("!")]
         logging.info("---> recv \"CTCP %s :%s\"" % (handle, msg[1:-1]))
         if msg[1:-1] == "VERSION":
             helpers.notice(self.parent.cli, handle, "\x01VERSION Pesterchum %s\x01" % (_pcVersion))
         return
     handle = nick[0:nick.find("!")]
     logging.info("---> recv \"PRIVMSG %s :%s\"" % (handle, msg))
     if chan == "#pesterchum":
         # follow instructions
         if msg[0:6] == "MOOD >":
             try:
                 mood = Mood(int(msg[6:]))
             except ValueError:
                 mood = Mood(0)
             self.parent.moodUpdated.emit(handle, mood)
         elif msg[0:7] == "GETMOOD":
             mychumhandle = self.mainwindow.profile().handle
             mymood = self.mainwindow.profile().mood.value()
             if msg.find(mychumhandle, 8) != -1:
                 helpers.msg(self.client, "#pesterchum",
                             "MOOD >%d" % (mymood))
     elif chan[0] == '#':
         if msg[0:16] == "PESTERCHUM:TIME>":
             self.parent.timeCommand.emit(chan, handle, msg[16:])
         else:
             self.parent.memoReceived.emit(chan, handle, msg)
     else:
         # private message
         # silently ignore messages to yourself.
         if handle == self.mainwindow.profile().handle:
             return
         if msg[0:7] == "COLOR >":
             colors = msg[7:].split(",")
             try:
                 colors = [int(d) for d in colors]
             except ValueError:
                 colors = [0,0,0]
             color = QtGui.QColor(*colors)
             self.parent.colorUpdated.emit(handle, color)
         else:
             self.parent.messageReceived.emit(handle, msg)