File tree 2 files changed +16
-4
lines changed
2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ def getConfig():
28
28
global tumblr_tumbling
29
29
global wolframalpha_api_key
30
30
global lastfm_api_key
31
+ global oauth_token
32
+ global oauth_secret
33
+ global consumer_key
34
+ global consumer_secret
31
35
config = ConfigParser ()
32
36
config .read ('config.ini' )
33
37
name = config .get ('main' , 'name' )
@@ -41,6 +45,10 @@ def getConfig():
41
45
tumblr_title = config .get ('tumblr' ,'post_titles' )
42
46
wolframalpha_api_key = config .get ('wolframalpha' , 'api_key' )
43
47
lastfm_api_key = config .get ('lastfm' , 'api_key' )
48
+ oauth_token = config .get ('twitter' , 'oauth_token' )
49
+ oauth_secret = config .get ('twitter' , 'oauth_secret' )
50
+ consumer_key = config .get ('twitter' , 'consumer_key' )
51
+ consumer_secret = config .get ('twitter' , 'consumer_secret' )
44
52
print ("I will use the name: " + name )
45
53
print ("I will connect to the server: " + server )
46
54
print ("I will connect to the channels: " + ", " .join (channels ))
Original file line number Diff line number Diff line change 3
3
from __future__ import unicode_literals
4
4
5
5
from twitter import Twitter
6
+ from twitter import OAuth
7
+ from botmily import config
6
8
import random
7
- #randomly return one of the last 50 tweets from https://twitter.com/TumblrTXT
9
+ #randomly return one of the last 200 tweets from https://twitter.com/TumblrTXT
10
+ #rate limit is 300 requests per 15 minutes
8
11
def tumblr (message_data , bot ):
9
- t = Twitter (api_version = 1 )
10
- tweetno = random .randint (0 ,49 )
11
- tweet = t .statuses .user_timeline .tumblrtxt (count = 50 )[tweetno ]
12
+ t = Twitter (api_version = 1.1 , auth = OAuth (config .oauth_token ,
13
+ config .oauth_secret , config .consumer_key , config .consumer_secret ))
14
+ tweetno = random .randint (0 ,199 )
15
+ tweet = t .statuses .user_timeline .tumblrtxt (count = 200 )[tweetno ]
12
16
return tweet ['text' ]
13
17
14
18
You can’t perform that action at this time.
0 commit comments