예제 #1
0
    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
파일: main.py 프로젝트: youxi/italkbot
 def get(self, mode=''):
     
     if mode == '':
         twitter = AppEngineTwitter()
         twitter.set_oauth(OAUTH_KEY, OAUTH_SECRET)
         req_token = self.request.get('oauth_token')
  
         query = OAuthRequestToken.all()
         query.filter('token = ', req_token)
         req_tokens = query.fetch(1)
  
         acc_token = twitter.exchange_oauth_tokens(req_token, req_tokens[0].secret)
         if (twitter.verify()==200):
             name = simplejson.loads(twitter.last_response.content)['screen_name']
             OAuthAccessToken( acc_token=acc_token['oauth_token'],
                               acc_secret=acc_token['oauth_token_secret'],
                               username=name.encode("utf-8")).put()            
             
             self.response.out.write(HEADER)
             self.response.out.write(JS)
             con_begin='''
             <div id="container">
             <div id="content">
             <h2>验证成功:)</h2>
             <P>恭喜你,%s,你已经成功授权TwiTalker并获取验证码和密钥,请<strong>务必首先保管好它们</strong></p>'''%(name.encode("utf-8"))
             self.response.out.write(con_begin)
             self.response.out.write("验证码: ")
             self.response.out.write(acc_token['oauth_token'])
             self.response.out.write("<br />密钥: ")
             self.response.out.write(acc_token['oauth_token_secret'])
             con_copy='''
             <form name="it">
             <textarea name="select1" rows="2" cols="120">-v '''+acc_token['oauth_token']+" "+acc_token['oauth_token_secret']+'''</textarea>
             <input onclick="copyit('it.select1')" type="button" value="复制绑定信息" name="cpy"></input>
             </form>
             '''
             self.response.out.write(con_copy)
 ##            db_ser = DBService()            
 ##            db_ser.setQuery('TwiCount')
 ##            twiNum=db_ser.getQuery()
 ##            num=twiNum.count()
 ##            if(num<250):
 ##                con_foot='<p>下一步: 推荐在GTalk添加'+ BOT +'为好友,并向该帐号发送以下格式绑定信息完成绑定:<br /><b>-v 空格 验证码 空格 密钥</b> (也可以直接复制框中信息并向机器人帐号发送)'+'</p>'
 ##            else:
 ##                con_foot='<p>目前没有可用机器人</p> '
         
 ##            self.response.out.write(con_foot)
             self.response.out.write('<p>如果你对验证过程仍有疑问,请参考<a href="faq">帮助页面</a></p>')
             
             self.response.out.write(FOOTER)
예제 #3
0
    def get(self):
        
        twitter = AppEngineTwitter()
        twitter.set_oauth(OAUTH_KEY, OAUTH_SECRET)
        req_token = self.request.get('oauth_token')
 
        query = OAuthRequestToken.all()
        query.filter('token = ', req_token)
        req_tokens = query.fetch(1)
 
        acc_token = twitter.exchange_oauth_tokens(req_token, req_tokens[0].secret)
 
        if (twitter.verify()==200):
            name = simplejson.loads(twitter.last_response.content)['screen_name']
            self.response.out.write(HEADER)
            self.response.out.write(JS)
            con_begin='''
            <div id="container">
            <div id="content">
            <h2>Congratulation!</h2>
            <P>Dear %s,you have got the Access Key and Access Secret.<strong>Please do keep them safely </strong>and finish the binding by the following steps:</p>'''%(name.encode("utf-8"))
            self.response.out.write(con_begin)
            self.response.out.write("Access Key:")
            self.response.out.write(acc_token['oauth_token'])
            self.response.out.write("<br />Access Secret: ")
            self.response.out.write(acc_token['oauth_token_secret'])
            con_copy='''
            <form name="it">
            <textarea name="select1" rows="2" cols="120">-v '''+acc_token['oauth_token']+" "+acc_token['oauth_token_secret']+'''</textarea>
            <input onclick="copyit('it.select1')" type="button" value="Copy" name="cpy"></input>
            </form>
            '''
            self.response.out.write(con_copy)
            db_ser = DBService()            
            db_ser.setQuery('TwiCount')
            twiNum=db_ser.getQuery()
            num=twiNum.count()
            if(num<250):
                con_foot='<p>Next Step: Add <b>'+ BOT +'</b> to your contact lists on GTalk\
sending the following command to the TwiTalker robot<br /><b>-v AccessKey AccessSecret</b>(Or just copy the verify infomation in the textarea and send it directly to the TwiTalker robot)'+'</p>'
            else:
                con_foot='<p>There is no TwiTalker robot available now.</p> '
        
            self.response.out.write(con_foot)
            self.response.out.write('<p>Visit <a href="faq">FAQ</a> if you need more help</p>')
            
            self.response.out.write(FOOTER)
예제 #4
0
    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)
예제 #5
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)