コード例 #1
0
ファイル: weixin.py プロジェクト: wanxiaopi/weixin
 def POST(self):
     str_xml = web.data() #获得post来的数据
     msg = PostMessage(str_xml) #解析消息信息
     mc = pylibmc.Client()      #初始化一个memcache实例用来保存用户的操作
     #获取用户当前状态
     data = mc.get(msg.fromUser)
     #用户没有进入任何服务状态
     if data is None :
         if msg.msgType =="text" and self.games.has_key(msg.content.strip()):
             #进入设定好的服务状态,并直接运行
             retmsg = self.games[msg.content.strip()](0).run(msg)
         else:
             retmsg = msg.reply_text(myService)
     else :
         strActClass,index =data.split("-")
         retmsg = eval(strActClass)(string.atoi(index)).run(msg)    
     return retmsg
     
コード例 #2
0
ファイル: weixin.py プロジェクト: NetWilliam/wx_public
 def POST(self):
     str_xml = web.data() #获得post来的数据
     msg = PostMessage(str_xml)
     self.logger.info(msg.getLogInfo())
     if msg.msgType == "text":
         if msg.content == u"音乐":
             music_obj = music.musicModule()
             music_info = music_obj.getRandomMusicList(1)[0]
             '''
             if music_info[music.INTRO] == "" && music_info[music.EXT_INFO] == "":
                 return msg.reply_text(music_info[music.NAME] + "\n" + music_info[music.AUTHOR] + "\n" + music_info[music.LINK])
             else if music_info[music.INTRO] == "" && music_info[music.EXT_INFO] != "":
             '''
             print music_info
             return msg.reply_text(music_info[music.INTRO] + "\n" + music_info[music.NAME] + " " + music_info[music.AUTHOR] + "\n" + music_info[music.LINK] + "\n" + music_info[music.EXT_INFO])
             #return msg.reply_text("wujiangwange http://music.163.com/#/m/song?id=355981 yujiyujinairuohe")
         else:
             return msg.reply_text("只响应 '音乐'")
     else:
         return msg.reply_text("现在只能响应文字消息, 其他的待开发")
コード例 #3
0
ファイル: weixin.py プロジェクト: waterbocai/gps-track
    def POST(self):
        str_xml = web.data()  #获得post来的数据
        msg = PostMessage(str_xml)  #解析消息信息
        #retmsg =msg.reply_text(str_xml)
        self.initConfig(msg)
        if msg.msgType.lower() == "event":
            self.logAccessUrl(msg)
            retmsg = self.event_handler(msg)
        else:
            retmsg = self.transferDialogue(msg)
        #1.优先进入对话状态

        #2.其次选择通话对象

        #3.最后进入服务咨询状态
        #retmsg = msg.reply_transfer_customer_service()
        return retmsg
コード例 #4
0
ファイル: weixin.py プロジェクト: wanxiaopi/weixin
 def POST(self):
     str_xml = web.data() #获得post来的数据
     msg = PostMessage(str_xml)
     return msg.auto_reply()
コード例 #5
0
sys.path.append(os.path.split(os.path.dirname(__file__))[0])

#import pylibmc
from common import templates_root
from message import GetMessage,PostMessage
from event import Subscribe

subscribe_xml="""
  <xml>
  <ToUserName><![CDATA[toUser]]></ToUserName>
  <FromUserName><![CDATA[FromUser]]></FromUserName>
  <CreateTime>123456789</CreateTime>
  <MsgType><![CDATA[event]]></MsgType>
  <Event><![CDATA[subscribe]]></Event>
  </xml>""" 
msg = PostMessage(subscribe_xml) 
print Subscribe("test").run(msg)

#subscribe_xml="""
#    <xml><ToUserName><![CDATA[toUser]]></ToUserName>
#    <FromUserName><![CDATA[FromUser]]></FromUserName>
#    <CreateTime>123456789</CreateTime>
#    <MsgType><![CDATA[event]]></MsgType>
#    <Event><![CDATA[subscribe]]></Event>
#    <EventKey><![CDATA[qrscene_123123]]></EventKey>
#    <Ticket><![CDATA[TICKET]]></Ticket>
#    </xml> """
#msg = PostMessage(subscribe_xml) 
#print msg.event=="subscribe" 
#print msg.eventKey=="qrscene_123123"  
#print msg.ticket=="TICKET"  
コード例 #6
0
ファイル: testPostMessage.py プロジェクト: wanxiaopi/weixin
    <FromUserName><![CDATA[fromUser]]></FromUserName>
    <CreateTime>1351776360</CreateTime>
    <MsgType><![CDATA[link]]></MsgType>
    <Title><![CDATA[公众平台官网链接]]></Title>
    <Description><![CDATA[公众平台官网链接]]></Description>
    <Url><![CDATA[url]]></Url>
    <MsgId>1234567890123456</MsgId>
    </xml>"""
#msg = PostMessage(str_xml)
#if msg.msgType == "text":
#    print msg.reply_text(msg.content)


#for msg in [text_msg,image_msg,voice_msg,video_msg,location_msg,link_msg,location_msg,link_msg]:
#    print PostMessage(msg).auto_reply()
picUrl = "http://www.qqfacebox.com/BiaoQin/UploadFiles_1237/200710/20071022135541401.gif"    
news =[]
news.append({
            "title"       : "小主,下次再来玩啊",
            "description" : "请输入任意内容获取服务列表 ",
            "picurl"      : picUrl,
            "url"         : myHomeUrl,
            })
news.append({
            "title"       : "小主,下次再来玩啊",
            "description" : "请输入任意内容获取服务列表 ",
            "picurl"      : picUrl,
            "url"         : myHomeUrl,
            })
obj = PostMessage(text_msg)
print obj.reply_news(news)
コード例 #7
0
    <xml>
    <ToUserName><![CDATA[toUser]]></ToUserName>
    <FromUserName><![CDATA[fromUser]]></FromUserName>
    <CreateTime>1351776360</CreateTime>
    <MsgType><![CDATA[location]]></MsgType>
    <Location_X>23.134521</Location_X>
    <Location_Y>113.358803</Location_Y>
    <Scale>20</Scale>
    <Label><![CDATA[位置信息]]></Label>
    <MsgId>1234567890123456</MsgId>
    </xml> """

link_msg ="""
    <xml>
    <ToUserName><![CDATA[toUser]]></ToUserName>
    <FromUserName><![CDATA[fromUser]]></FromUserName>
    <CreateTime>1351776360</CreateTime>
    <MsgType><![CDATA[link]]></MsgType>
    <Title><![CDATA[公众平台官网链接]]></Title>
    <Description><![CDATA[公众平台官网链接]]></Description>
    <Url><![CDATA[url]]></Url>
    <MsgId>1234567890123456</MsgId>
    </xml>"""
#msg = PostMessage(str_xml)
#if msg.msgType == "text":
#    print msg.reply_text(msg.content)


for msg in [text_msg,image_msg,voice_msg,video_msg,location_msg,link_msg,location_msg,link_msg]:
    print PostMessage(msg).auto_reply()