Skip to content

Commit 9a98a7b

Browse files
committed
Checked that the program runs correctly on Unix-based OS (Mac and Linux).
1 parent 7deffd3 commit 9a98a7b

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

README

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,31 @@ This bot runs in the following ways.
44

55
2. Re-tweet the tweets.
66

7-
In example, 'search_term' is 'Cafe Miyama',
7+
In this example, 'search_term' is 'Cafe Miyama',
88
and you can see how it behaves by checking the following account.
99

1010
http://twitter.com/cafemiyamabot
1111

1212

13-
HOW TO SETUP (work in progress):
13+
HOW TO SETUP:
1414
1. Register your OAuth client on Twitter
1515
URL: http://twitter.com/oauth_clients
16-
* you MUST choose 'client' for Simple Twitter Bot.
16+
NOTE: You MUST change permission settings to "Read & Write" if you wanna update via API.
17+
The default is "Read Only".
1718

1819
2. Run 'python register_pin.py' and
1920
use CONSUMER_KEY and CONSUMER_SECRET you got from the registeration.
21+
NOTE: Make sure you are now signing in Twitter as your Bot account when visiting a given URL.
2022

21-
3. Change setting variables(e.g. CONSUMER_KEY, CONSUMER_SECRET) in main.py
23+
3. Change setting variables (CONSUMER_KEY and CONSUMER_SECRET) in main.py to the given ones.
2224

2325
4. Run Google App Engine dev_server and visit the following URL
2426
URL: http://localhost:8080/cron/update
25-
* If you finish all of your setting, set debug_flag in main.py off.
27+
* If you finish all of your setting, set 'debug_flag' in main.py off.
2628

2729
5. Done!
2830

2931
Enjoy developing your own twitter bot!
3032

31-
Yohei Yasukawa
33+
YasuLab
3234

main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#debug_flag = True
1212
debug_flag = False
1313
MAX_LEN = 140
14-
SEARCH_TERM = u'"Cafe Miyama" OR カフェミヤマ'
14+
SEARCH_TERM = u'Cafe Miyama'
1515
CONSUMER_KEY = "???"
1616
CONSUMER_SECRET = "???"
1717
KEY_FILE_API = "api_key.dat"
18-
KEY_FILE_TWITTER = "twitter_key.dat"
18+
1919
BOT_USERNAME = "CafeMiyamaBot"
20-
BOT_PASSWORD = "???"
20+
2121

2222
def oauth_twitter():
2323
access_token = pickle.load(file(KEY_FILE_API))
@@ -41,7 +41,7 @@ def twitter_api_init_gae(self,
4141
self._input_encoding = input_encoding
4242
self.SetCredentials(username, password)
4343

44-
def run(name, pswd, search_term):
44+
def run(search_term):
4545
acc_token = pickle.load(file(KEY_FILE_API))
4646
gae_twitter = AppEngineTwitter()
4747
gae_twitter.set_oauth(CONSUMER_KEY,
@@ -52,7 +52,7 @@ def run(name, pswd, search_term):
5252
results = gae_twitter.search(search_term.encode('utf8'), {'rpp': 20})
5353
api = oauth_twitter() #twitter.Api(username=bot_username, password=bot_password)
5454
escape_user_list = []
55-
escape_user_list.append(name)
55+
escape_user_list.append(BOT_USERNAME)
5656

5757
# Get most corrently tweeted tweet
5858
status = api.GetUserTimeline()
@@ -149,4 +149,4 @@ def run(name, pswd, search_term):
149149
twitter.Api.__init__ = twitter_api_init_gae
150150

151151
# Start to run
152-
run(BOT_USERNAME, BOT_PASSWORD, SEARCH_TERM)
152+
run(SEARCH_TERM)

regist_pin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys, os, pickle
55
from oauthtwitter import *
66

7-
KEY_FILE_API = "Api_key.dat"
7+
KEY_FILE_API = "api_key.dat"
88

99
def twitter():
1010
if os.path.isfile(KEY_FILE_API):

0 commit comments

Comments
 (0)