def privatemessage(self,s): msg = pyfflermi.PrivateMessage() msg.dejsonify(s) self.data.createMessage(msg.fromName,msg.toName,msg.text,"<PM>",board='__pyffle_pm') resmsg = pyfflermi.ServerResult(110,"PM sent") response = pyfflermi.getMessage(resmsg) print response
def onlinelist(self,s): names = [] for entry in self.data.getCurrentlyonEntries(): names.append(entry.username) thelist = pyfflermi.Onlinelist(names) response = pyfflermi.getMessage(thelist) print response
def chatmessage(self,s): chatmsg = pyfflermi.ChatMessage("") chatmsg.dejsonify(s) self.data.createMessage(self.currentUser.username,None,"chat message",chatmsg.msg,board='__pyffle_chat') sysres = pyfflermi.ChatMessageResult(0,"") response = pyfflermi.getMessage(sysres) print response
def chatupdaterequest(self,s): ## we don't care about the data in the request, we don't do rooms yet req = pyfflermi.ChatUpdateRequest() req.dejsonify(s) status = req.room print "STATUS |" + status + "|" if status.strip().lower() == "enter": self.addToChatList(self.currentUser.username) if status.strip().lower() == "exit": self.removeFromChatList(self.currentUser.username) res = pyfflermi.ChatUpdateResult() ## except if this is an enter or exit message chatBoard = self.data.getBoardByName("__pyffle_chat") self.newmsgids = self.data.getMessagesSince(chatBoard,self.lastCheck,checkSrm = False) newmessages = [] for msgid in self.newmsgids: msg = self.data.getMessage(msgid) msgtext = [] while msgtext == []: ## due to DB delays, the msg text might not be stored yet whilst the messge is.. msgtext = self.data.getMessagetexts(msgid) newmessages.append((msg.fromname,msgtext[0])) self.lastCheck = datetime.now() res.newmessages = newmessages users = self.getChatList() res.users = users response = pyfflermi.getMessage(res) print response
def userlist(self,s): usernamelist = [] users = self.data.getUsers() for user in users: usernamelist.append(user.username) thelist = pyfflermi.Userlist(usernamelist) response = pyfflermi.getMessage(thelist) print response
def poll(self,s): pm = self.getPms() themsg = None if pm == None: themsg = pyfflermi.ServerResult(0,"Ping") else: themsg = pm response = pyfflermi.getMessage(themsg) print response
def messageheader(self,s): print "S=" + str(s) req = pyfflermi.MessageHeaderRequest() req.dejsonify(s) print "Getting message: " + str(req.msgid) msg = self.data.getMessage(req.msgid) outmsg = pyfflermi.MessageHeader(req.msgid,msg.fromname,msg.toname,msg.subject,msg.readbyrecipient,str(msg.sentdate)) response = pyfflermi.getMessage(outmsg) print response
def clientmessage(self,s): print "S=" + str(s) req = pyfflermi.ClientMessage() req.dejsonify(s) print "Posting to board " + req.boardname self.data.createMessage(req.fromHdr,req.toHdr,req.subject,req.text,req.boardname) sysres = pyfflermi.ServerResult(100,"Posted") response = pyfflermi.getMessage(sysres) print response
def messagecount(self,s): print "S=" + str(s) req = pyfflermi.MessagecountRequest() req.dejsonify(s) #print "Looking at board: " + req.boardname count = self.data.getBoardMessageCount(req.boardname) msg = pyfflermi.MessagecountResult(count,req.boardname) response = pyfflermi.getMessage(msg) print response
def messagerequest(self,s): print "S=" + str(s) req = pyfflermi.MessageRequest() req.dejsonify(s) print "Getting message texts: " + str(req.msgid) msgtexts = self.data.getMessagetexts(req.msgid) msgattaches = [] outmsg = pyfflermi.Message(req.msgid,msgtexts,msgattaches) response = pyfflermi.getMessage(outmsg) print response
def imagerequest(self,s): print "S=" + str(s) req = pyfflermi.ImageRequest() req.dejsonify(s) filename = self.images[req.imagename] f = open(filename) data = f.read() f.close() payload = base64.b64encode(data) payload = payload.replace("\n","") outmsg = pyfflermi.Image(payload) response = pyfflermi.getMessage(outmsg) print response
def loginrequest(self,s): #print "S=" + str(s) req = pyfflermi.LoginRequest("","") req.dejsonify(s) #print "Username: "******"Password: "******"Welcome to hq.pyffle.com") self.loggedIn = True self.data.setCurrentlyonActivity("GUI Mode") else: outmsg = pyfflermi.LoginResult(-1,"Invalid credentials") response = pyfflermi.getMessage(outmsg) print response
def mainloop(self): ## read input print "!|!PYFFLEGUI 0.23 wtf" LoggedOut = False self.deathTimer = Timer(self.TIMEOUT,self.checkDeath) self.deathTimer.start() while not LoggedOut: line = sys.stdin.readline() loggedIn = self.processData(line) if not loggedIn: LoggedOut = True logoutMessage = pyfflermi.ServerResult(0,"Goodbye.") response = pyfflermi.getMessage(logoutMessage) print response os._exit(0)
def messagelist(self,s): print "S=" + str(s) req = pyfflermi.MessagelistRequest() req.dejsonify(s) #print "Looking at board: " + req.boardname msgids = [] if req.boardname == "__pyffle_email": #print "Username="******"SENDING MSGIDS " + str(msgids) else: msgids = self.data.getMessagesByBoardname(req.boardname) print "Non email board, ids: " + str(msgids) thelist = pyfflermi.Messagelist(msgids) response = pyfflermi.getMessage(thelist) print response
def boardlist(self,s): print "DATA=" + str(self.data) thelist = pyfflermi.Boardlist(self.data.getBoardNames()) response = pyfflermi.getMessage(thelist) print response