Пример #1
0
 def process_message(self, e):
     msg = e.GetString()
     if msg[:6].lower() == "/join ": # better way to do this? probably. I'll refactor later. FLW.
         event = wx.PyCommandEvent(EVT_JOIN_ROOM.typeId, ID_JOIN_ROOM)
         event.SetString(msg[6:])
         wx.PostEvent(frame.sock.handler, event)
         #frame.sock.handler.ProcessEvent(event)
         wx.PostEvent(frame, event)
         #frame.GetEventHandler().ProcessEvent(event)
         # feels wrong, but e.Skip and e.ResumePropagation
         # aren't working as I would expect
         # TRY: trawl wxpy-demo?
         printevent = wx.PyCommandEvent(EVT_PRINT_MESSAGE.typeId, ID_PRINT_MESSAGE)
         printevent.SetString("Joining " + msg[6:])
         printevent.SetClientData(self.roomtitle)
         wx.PostEvent(frame, printevent)
         #frame.GetEventHandler().ProcessEvent(printevent)
         e.GetClientObject().Clear()
         return
     elif msg[:6].lower() == "/roll ":
         msg = msg[6:]
         result, valid = extras.roll(msg)
         report = "rolling %s: %s" % (msg, result)
         printevent = wx.PyCommandEvent(EVT_PRINT_MESSAGE.typeId, ID_PRINT_MESSAGE)
         printevent.SetString(report)
         printevent.SetClientData(self.roomtitle)
         event = wx.PyCommandEvent(EVT_SEND_MESSAGE.typeId, ID_SEND_MESSAGE)
         event.SetString(report)
         event.SetClientData(self.roomtitle)
         wx.PostEvent(frame.sock.handler, event)
         wx.PostEvent(frame, printevent)
         #frame.sock.handler.ProcessEvent(event)
         #frame.GetEventHandler().ProcessEvent(printevent)
         e.GetClientObject().Clear()
         return
     elif msg:
         event = wx.PyCommandEvent(EVT_SEND_MESSAGE.typeId, ID_SEND_MESSAGE)
         event.SetString(msg)
         event.SetClientData(self.roomtitle)
         wx.PostEvent(frame.sock.handler, event)
         #frame.sock.handler.ProcessEvent(event)
         printevent = wx.PyCommandEvent(EVT_PRINT_MESSAGE.typeId, ID_PRINT_MESSAGE)
         printevent.SetString("me: " + msg)
         printevent.SetClientData(self.roomtitle)
         wx.PostEvent(frame, printevent)
         #frame.GetEventHandler().ProcessEvent(printevent)
         e.GetClientObject().Clear()
Пример #2
0
 def botParse(self, nick, room, msg):
     #botcommands = {'roll':}
     if ' ' in msg:
         cmd, msg = msg.split(' ',1)
         if cmd.lower() == 'roll':
             result, valid = extras.roll(msg)
             report = "%s is rolling %s: %s" % (nick, msg, result)
             if len(report) > 480:
                 report = "Seriously, %s? You crazy." % nick
             printevent = wx.PyCommandEvent(EVT_PRINT_MESSAGE.typeId, ID_PRINT_MESSAGE)
             printevent.SetString(report)
             printevent.SetClientData(room)
             event = wx.PyCommandEvent(EVT_SEND_MESSAGE.typeId, ID_SEND_MESSAGE)
             event.SetString(report)
             event.SetClientData(room)
             wx.PostEvent(frame.sock.handler, event)
             wx.PostEvent(frame, printevent)
             #frame.sock.handler.ProcessEvent(event)
             #frame.GetEventHandler().ProcessEvent(printevent)
             return