コード例 #1
0
ファイル: twi_site.py プロジェクト: denyany/twitalker
    def get(self):
      
        twitter = AppEngineTwitter()
        twitter.set_oauth(key=OAUTH_KEY, secret=OAUTH_SECRET)
        req_info = twitter.prepare_oauth_login()
        
        OAuthRequestToken(token=req_info['oauth_token'],
                          secret=req_info['oauth_token_secret']).put()
        
        # get the oauth url
        oauth_url=xml.sax.saxutils.escape(req_info['url'], {'"': """})
        # oauth_url=h(req_info['url'])


        content='''
        <div id="container">
        <div id="intro"><h2>Tweet  It  Easy</h2>
        <p>TwiTalker is a powerful Twitter robot based on Google Talk.To sign up and use TwiTalker,
        click the <a href="%s">login in with Twitter</a> Button on the right in order to verify and bind to your account.
        <a href="faq">( How to verify? )</a>.Go to FAQ page if you need help and follow<a href="http://twitter.com/Twi_Talker">@Twi_Talker</a>
        to get notifications about updates and changes to TwiTalker. <br /></p>

        <h2>Commands: </h2>
        <p>Get help and command list: -help</p>
        <p>Bind to account: -v AccessKey AccessSecret</p>
        <p>Remove binding: -remove</p>
        <p>Set on-mode (receive tweets and DM from your friends): -on</p>
        <p>Set self-mode (only received mentioned tweets and DM):-self</p>
        <p>Set off-mode(never receive tweets):-off</p>
        <p>Retrieve latest mentioned tweets: -@</p>
        <p>Retrieve latest direct message: -d</p>
        <p><a href="faq">Go to FAQ page to get more commands....</a></p>
        </div>

        <div id="step">
        <h2>OAuth</h2>
        <a href="%s"><img style="margin-bottom:0px" src="img/login.png" /></a><br />
        <h2>About TwiTalker</h2>
        <p>TwiTalker is developed by <a href="http://www.kavingray.com">Kavin</a> (Follow <a href="http://twitter.com/kavin_gray">Kavin</a> on twitter).
        It's Powered by Google app engine platforms.This service provides a different and easy way for you to use Twitter.
        You can send tweet and receive friends' updates directly in Gtalk without login in your Twitter account.</p>
        <img style="margin-bottom:0px" src="img/tie.png" />
        </div>
        <div class="clean"></div>
        </div>
        '''%(oauth_url,oauth_url)
    
        # initing the pages    
        self.response.out.write(HEADER)    
        self.response.out.write(content)
        self.response.out.write(FOOTER)
コード例 #2
0
ファイル: twi_site.py プロジェクト: denyany/twitalker
    def get(self):
      
        twitter = AppEngineTwitter()
        twitter.set_oauth(key=OAUTH_KEY, secret=OAUTH_SECRET)
        req_info = twitter.prepare_oauth_login()
        
        OAuthRequestToken(token=req_info['oauth_token'],
                          secret=req_info['oauth_token_secret']).put()
        
        # get the oauth url
        oauth_url=xml.sax.saxutils.escape(req_info['url'], {'"': "&quot;"})
        # oauth_url=h(req_info['url'])


        content='''
        <div id="container">
        <div id="intro"><h2>Tweet  It  Easy</h2>
        <p>TwiTalker是一款第三方应用,提供推特Gtalk机器人服务,通过添加TwiTalker在Gtalk上的帐号您可以方便地在Gtalk上更新自己的推特和接收好友消息。如果第一次使用TwiTalker请<a href="%s">登陆</a>验证获取验证码和密钥(<a href="faq">如何获取</a>),以便Gtalk绑定推特帐号,具体验证绑定过程详见帮助。欢迎在推特上Follow <a href="https://twitter.com/Twi_Talker">@Twi_Talker</a>以获取最新消息和更新。<br /></p>
        <h2>TwiTalker 功能格式</h2>
        <p>查看帮助: -help</p>
        <p>绑定用户:-v 空格 认证码 空格 密钥 </p>
        <p>删除绑定:-remove</p>
        <p>开启完全消息接收(接收好友消息和私信):-on</p>
        <p>开启自我消息接收(只接受好友@我消息和私信):-self</p>
        <p>完全关闭消息接收(屏蔽所有消息):-off</p>
        <p>查看最近回复:-@</p>
        <p>查看最近私信:-d</p>
        <p><a href="faq">更多功能请参考帮助....</a></p>
        </div>

        <div id="step">
        <h2>OAuth验证(需翻墙)</h2>
        <a href="%s"><img style="margin-bottom:0px" src="img/login.png" /></a><br />
        <h2>工作原理</h2>
        <p>TwiTalker利用Google appengine为平台架设,通过OAuth验证,用户不需提供密码就可以把自己的Gtalk帐号和推特绑定在一起,这样就可以通过Gtalk更新自己的推特消息,由于考虑服务器负载问题,每个TwiTalker机器人帐号好友上限是250人。TwiTalker已经开源,如果您对TwiTalker的原理和开发感兴趣,欢迎查看项目主页或联系开发者<a href="https://twitter.com/kavin_gray">@Kavin_Gray</a></p>
        <img style="margin-bottom:0px" src="img/tie.png" />
        </div>
        <div class="clean"></div>
        </div>
        '''%(oauth_url,oauth_url)
    
        # initing the pages    
        self.response.out.write(HEADER)    
        self.response.out.write(content)
        self.response.out.write(FOOTER)
コード例 #3
0
ファイル: main.py プロジェクト: youxi/italkbot
    def get(self):
        twitter = AppEngineTwitter()
        twitter.set_oauth(key=OAUTH_KEY, secret=OAUTH_SECRET)
        req_info = twitter.prepare_oauth_login()
        
        OAuthRequestToken(token=req_info['oauth_token'],
                          secret=req_info['oauth_token_secret']).put()
        
        # get the oauth url
        oauth_url=xml.sax.saxutils.escape(req_info['url'], {'"': "&quot;"})
        # oauth_url=h(req_info['url'])

        content='''
        <div id="container">
        <div id="intro"><h2>Tweet  It  Easy</h2>
        <p>TwiTalker是一款第三方应用,提供推特Gtalk机器人服务,通过添加TwiTalker在Gtalk上的帐号您可以方便地在Gtalk上更新自己的推特和接收好友消息。如果第一次使用TwiTalker请<a href="%s">登陆</a>验证获取验证码和密钥(<a href="faq">如何获取</a>),以便Gtalk绑定推特帐号,具体验证绑定过程详见帮助。欢迎在推特上Follow <a href="https://twitter.com/Twi_Talker">@Twi_Talker</a>以获取最新消息和更新。<br /></p>
        <h2>TwiTalker 功能格式</h2>
        <p>你大爷,烦死了</p>
        </div>

        <div id="step">
        <h2>OAuth验证(需翻墙)</h2>
        <a href="%s"><img style="margin-bottom:0px" src="img/login.png" /></a><br />
        <h2>工作原理</h2>
        <p>TwiTalker利用Google appengine为平台架设,通过OAuth验证,用户不需提供密码就可以把自己的Gtalk帐号和推特绑定在一起,这样就可以通过Gtalk更新自己的推特消息,由于考虑服务器负载问题,每个TwiTalker机器人帐号好友上限是250人。TwiTalker已经开源,如果您对TwiTalker的原理和开发感兴趣,欢迎查看项目主页或联系开发者<a href="https://twitter.com/kavin_gray">@Kavin_Gray</a></p>
        <img style="margin-bottom:0px" src="img/tie.png" />
        </div>
        <div class="clean"></div>
        </div>
        '''%(oauth_url,oauth_url)
    
        # initing the pages    
##        self.response.out.write(HEADER)    
##        self.response.out.write(content)
##        self.response.out.write(FOOTER)
        
        datefrom = str(int((datetime.datetime.utcnow()+datetime.timedelta(hours=+8)).strftime("%Y%m%d")) - 1) + '000000'
        dateto   = (datetime.datetime.utcnow()+datetime.timedelta(hours=+8)).strftime("%Y%m%d%H%M%S")
        fxtest = fxdb.all()
        fxtest.filter('indexTime >=', datefrom).filter('indexTime <=', dateto)
        fxtest.order('indexTime')
        hello=[]
        hello = fxtest.fetch(limit=310)
        self.response.out.write(HEADER)
        dd=[]
        for helloline in hello:
            dd.append(str(helloline.audOfferRate))
        datastr = ",".join(dd)
        maxmin = [str(float(min(dd)) - 0.2), str(float(max(dd)) + 0.2)]
        maxminstr = ",".join(maxmin)
        
        fxHist = fxdb.all()
        fxtest.filter('indexTime >=', datefrom).filter('indexTime <=', dateto)
        fxHist.order('-audOfferRate')
        maxRateTime = fxHist.get().audUpdateTime
        
        fxHist = fxdb.all()
        fxtest.filter('indexTime >=', datefrom).filter('indexTime <=', dateto)
        fxHist.order('audOfferRate')
        minRateTime = fxHist.get().audUpdateTime
        logging.debug('datefrom: %s  dateto: %s' %(datefrom,dateto))  
        logging.debug('minRate: %s  maxRate: %s' %(str(float(min(dd))),str(float(max(dd)))))
        logging.debug('minTime: %s  maxTime: %s' %(str(minRateTime),str(maxRateTime))) 
        logging.debug('maxminstr: %s' %(maxminstr))     
        
        img='''
        <img src="//chart.googleapis.com/chart?chs=400x150&cht=lc&chds=%s&chd=t:%s&chls=1" width="400" height="150" alt="" />'''%(maxminstr,datastr)
        cons='''
        <div id="container">
        <div id="intro"><h2>Tweet  It  Easy</h2>
        <p>%s<br /></p>
        <h2>TwiTalker 功能格式</h2>
        <p>你大爷,烦死了</p>
        今日最低点: %s 时间: %s
        今日最高点: %s 时间: %s
        </div>
        '''%(img,str(float(min(dd))),str(minRateTime),str(float(max(dd))),str(maxRateTime))
        self.response.out.write(cons)