예제 #1
0
파일: suanming.py 프로젝트: Crackpot/gftop
 def render(self, request):
     self.serviceid = request.args.get('ServiceId', [''])[0]
     self.phone = request.args.get('Phone', [None])[0]
     self.msg = request.args.get('Msg', [''])[0]
     self.spnumber = request.args.get('SpNumber', ['1062376618'])[0]
     self.linkid = request.args.get('LinkId', [None])[0]
     
     _logmsg = '%s: %s\r\n' % (
         datetime.datetime.today(), 
         common.args2str(request.args)
     )
     log.write(_logmsg)        
 
     if len(self.msg) > self.cmd_length:
         self.o2 = self.msg[self.cmd_length]
         
     if self.phone and self.linkid and self.msg and self.msg.startswith(self.cmd):
         mtstep_key = "%s|%s" % (self.nid, self.phone)
         self.request_mtstep(
             request, 
             mtstep_key,
             phone=self.phone,
             linkid = self.linkid,
             serviceid = self.serviceid,
             spnumber = self.spnumber
         )
         
         if self.response_delay:
             return server.NOT_DONE_YET
         
         return self.response_value
     return self.response_value
예제 #2
0
    def render(self, request):
        self.phone = request.args.get('phone', [None])[0]
        self.msg = request.args.get('msgcontent', [''])[0]
        self.linkid = request.args.get('linkid', [None])[0]
        self.serviceup = request.args.get('serviceup', ['100'])[0]
        self.ext = request.args.get('ext', ['7'])[0]

        _msg = '%s: %s\r\n' % (
            datetime.datetime.today(),
            common.args2str(request.args)
        )
        log.write(_msg)

        self.cmd = '802' #发送的指令
        self.ln = '1062666777' #用户上行号码
        self.cmd_length = len(self.cmd)

#        self.o2 = '-1'   #用户的选择判断
#        if len(self.msg) > self.cmd_length:
#            self.o2 = self.msg[self.cmd_length]



        if self.phone and self.linkid and self.msg and self.msg.startswith(self.cmd):
            mtstep_key = "%s|%s" % (self.nid, self.phone)
            d = proxycache.pcache.perform("getmtstep", mtstep_key)
            d.addCallback(self._got_mtstep_ok)
            d.addErrback(self._got_mtstep_error)
            d.addCallback(self.mt_send,
                request,
                mtstep_key,
                phone=self.phone,
                linkid=self.linkid,
                serviceup=self.serviceup,
                ext=self.ext
            )
            return "0"
        return "-1"