summaryrefslogtreecommitdiff
path: root/JKTwitterBot/src/thebot.py
diff options
context:
space:
mode:
authorBasherSlash@gmail.com <BasherSlash@gmail.com>2011-05-15 02:08:28 +0000
committerBasherSlash@gmail.com <BasherSlash@gmail.com>2011-05-15 02:08:28 +0000
commitc5eebe83ab0672e5d34b87360bafcbb3a689f10c (patch)
tree8da64bf0fa14cfeae8fc283e322a7c305a15b013 /JKTwitterBot/src/thebot.py
parentd5cffd711ed31debd27f9054a848bea642cc59d3 (diff)
More or less all features are implemented needs some review and explore possible changes.
Diffstat (limited to 'JKTwitterBot/src/thebot.py')
-rw-r--r--JKTwitterBot/src/thebot.py44
1 files changed, 37 insertions, 7 deletions
diff --git a/JKTwitterBot/src/thebot.py b/JKTwitterBot/src/thebot.py
index ed63724..7f8ed04 100644
--- a/JKTwitterBot/src/thebot.py
+++ b/JKTwitterBot/src/thebot.py
@@ -9,10 +9,12 @@ from optparse import OptionParser
import pickle
import os
import time
+import json
+import urllib2
CONSUMER_KEY='uS6hO2sV6tDKIOeVjhnFnQ'
CONSUMER_SECRET='MEYTOS97VvlHX7K1rwHPEqVpTSqZ71HtvoK4sVuYk'
-DEFAULT_USERNAME = 'ziggster00' "this will need to be changed"
+DEFAULT_USERNAME = 'ziggster00' # "this will need to be changed"
DEFAULT_AUTH_FILENAME = '.twitter_oauth'
DEFAULT_LASTID_FILENAME = '.twitter_lastid'
Response_File = 'Response.txt'
@@ -89,9 +91,9 @@ if __name__ == '__main__':
poster.friendships.destroy(id=user)
poster.friendships.create(id=user)
- for friend in friends:
+ for friend in friends: # adds all friends from friends.txt
follow_user(friend)
-
+
while True:
results = reader.search(q=username, since_id=lastid)['results']
for result in reversed(results):
@@ -110,7 +112,8 @@ if __name__ == '__main__':
response_count = response_count+1
print '====> Resp = %s' % outgoing_text
try:
- status_update(outgoing_text)
+ print outgoing_text
+ #status_update(outgoing_text)
except TwitterError as e:
print '*** Twitter returned an error:\n***%s' % e
else:
@@ -123,11 +126,38 @@ if __name__ == '__main__':
count = 0
print count
print tweet[count]
- status_update(tweet[count]) # post a status update
+ #status_update(tweet[count]) # post a status update
print 'Now sleeping... \n'
time.sleep(120) # set at 5min but is at 2min
print question[count]
- status_update(question[count])
+ #status_update(question[count])
print 'Now sleeping... \n'
time.sleep(120) # set for 2min.
- count = count+1 \ No newline at end of file
+ # may want to add ask questions to friends too
+ # Ask questions specific to followers
+ connection = urllib2.urlopen('http://api.twitter.com/1/statuses/followers.json?screen_name=' + username)
+ friendship = urllib2.urlopen('http://api.twitter.com/1/statuses/friends.json?screen_name=' + username)
+ following_str = connection.read()
+ following_obj = json.loads(following_str)
+ friend_str = friendship.read()
+ friend_obj = json.loads(friend_str)
+ following_list = []
+ friend_list = []
+ for i in range(len(following_obj)):
+ followers = following_obj[i]
+ following_list.append(followers[u'screen_name'])
+ for x in range(len(friend_obj)):
+ supfriend = friend_obj[x]
+ friend_list.append(supfriend[u'screen_name'])
+ postnumber = count
+ for follow_me in friend_list:
+ if not (follow_me in following_list):
+ post = follow_me + ' ' + question[postnumber]
+ #status_update(post) #May want to ask everyone questions regardless of friendship
+ time.sleep(30)
+ postnumber = postnumber + 1
+ if (follow_me in following_list):#Left open if we want to make specific questions to friends
+ print follow_me
+ if postnumber == len(question):
+ postnumber = 0
+ count = count + 1 \ No newline at end of file