示例#1
0
 def tweet_rss(self, feed_name, addtags):
     # try:
     ref = rsswidget.get_update(feed_name, bebukey=self.auth['BEBUKEY'])
     print("Retrieved tweet from RSS %s" % (ref['tweet']))
     hashtags = basicbot.tag_it(ref['title'], addtags)
     tweet_post = """{} {}""".format(ref['tweet'][0:260], hashtags)
     print("Tweeting post:  %s" % (tweet_post))
     self.tw.tweet(tweet_post)
示例#2
0
 def tweet_top_tweet(self, terms="", hashtags="#news"):
     tt = self.tw.get_top_tweet()
     hashtags = basicbot.tag_it(tt.text, hashtags)
     intro = """{}""".format(self.re.get_intro(tt.text))[:278]
     print("Tweet Intro: ", intro)
     print("Tweet Text: ", tt.text)
     try:
         self.tw.tweet_comment(tt, intro, hashtags)
     except Exception as e:
         print(e)
         print("Unable to tweet.")
示例#3
0
 def tweet_pubmed(self, feed_name, addtags):
     try:
         ref = rsswidget.get_update(feed_name, bebukey=self.auth['BEBUKEY'])
         print("Retrieved tweet from pubmed %s" % (ref['tweet']))
         hashtags = basicbot.tag_it(ref['title'], addtags)
         tweet_post = """{} {}""".format(ref['tweet'], hashtags)
         print("Tweeting post:  %s" % (tweet_post))
         self.tw.tweet(tweet_post)
     except Exception as e:
         print(e)
         print("Unable to get pubmed update")
         self.tweet_top_tweet()
示例#4
0
 def tweet_reddit(self, subreddit, hashtags="#news"):
     # try:
     # creds = self.load_reddit_creds()
     creds = self.auth
     #print(get_update(env.client_id,env.client_secret,env.user_agent,"science"))
     print("Getting post")
     post = redditwidget.get_update(creds['REDDIT_CLIENT_ID'],
                                    creds['REDDIT_CLIENT_SECRET'], ua,
                                    subreddit, 5, self.auth['BEBUKEY'])
     print("Tagging post")
     try:
         add_tags = basicbot.tag_it(post['title'], hashtags)
     except:
         add_tags = hashtags
     tweet_post = """{} {}""".format(post['tweet'], add_tags)
     print("Tweeting post:  %s" % (tweet_post))
     self.tw.tweet(tweet_post)
示例#5
0
 def tweet_news(self, topic, addtags):
     print("Tweeting news")
     print("topic " + topic)
     news = newswidget.get_update(topic, self.auth['BEBUKEY'])
     if (news):
         hashtags = basicbot.tag_it(' '.join(news['keywords']), addtags)
         new_tweet = """{} {} {}""".format(news['title'], news['url'],
                                           hashtags)
         print("Response: ", new_tweet)
         try:
             self.tw.tweet(new_tweet)
             return
         except Exception as e:
             print(e)
             print("Unable to tweet news.")
     else:
         print('No news is good news')
         self.tweet_top_tweet()