'del',
'ufav',
's',
- 'fr',
+ 'show',
'fl',
+ 'ufl',
'h',
'c',
'q'
media_url = []
media = t['entities']['media']
for m in media:
- media_url = m['media_url']
+ media_url.append(m['media_url'])
except:
media_url = None
# Display Image
if imgflg and media_url:
- response = requests.get(media_url)
- image_to_display(StringIO(response.content))
+ for mu in media_url:
+ response = requests.get(mu)
+ image_to_display(StringIO(response.content))
def parse_arguments():
printNicely(red('Sorry I can\'t understand.'))
-def friend():
+def show():
"""
- List of friend (following)
+ Show image
"""
t = Twitter(auth=authen())
- g['friends'] = t.friends.ids()['ids']
- for i in g['friends']:
- name = t.users.lookup(user_id=i)[0]['name']
- screen_name = '@' + t.users.lookup(user_id=i)[0]['screen_name']
- user = cycle_color(name) + grey(' ' + screen_name + ' ')
- print user
+ try:
+ target = g['stuff'].split()[0]
+ if target != 'image':
+ return
+ id = int(g['stuff'].split()[1])
+ tid = db.rainbow_query(id)[0].tweet_id
+ tweet = t.statuses.show(id=tid)
+ media = tweet['entities']['media']
+ for m in media:
+ res = requests.get(m['media_url'])
+ img = Image.open(StringIO(res.content))
+ img.show()
+ except:
+ printNicely(red('Sorry I can\'t show this image.'))
-def follower():
+def follow():
"""
- List of follower
+ Follow a user
"""
t = Twitter(auth=authen())
- g['followers'] = t.followers.ids()['ids']
- for i in g['followers']:
- name = t.users.lookup(user_id=i)[0]['name']
- screen_name = '@' + t.users.lookup(user_id=i)[0]['screen_name']
- user = cycle_color(name) + grey(' ' + screen_name + ' ')
- print user
+ screen_name = g['stuff'].split()[0]
+ if screen_name[0] == '@':
+ try :
+ t.friendships.create(screen_name=screen_name[1:],follow=True)
+ printNicely(green('You are following ' + screen_name + ' now!'))
+ except:
+ printNicely(red('Sorry can not follow at this time.'))
+ else:
+ printNicely(red('Sorry I can\'t understand.'))
+
+
+def unfollow():
+ """
+ Unfollow a user
+ """
+ t = Twitter(auth=authen())
+ screen_name = g['stuff'].split()[0]
+ if screen_name[0] == '@':
+ try :
+ t.friendships.destroy(screen_name=screen_name[1:],include_entities=False)
+ printNicely(green('Unfollow ' + screen_name + ' success!'))
+ except:
+ printNicely(red('Sorry can not unfollow at this time.'))
+ else:
+ printNicely(red('Sorry I can\'t understand.'))
def help():
yellow('[id=12]') + '.\n'
usage += s * 2 + green('s #AKB48') + ' will search for "' + \
yellow('AKB48') + '" and return 5 newest tweet.\n'
- usage += s * 2 + green('fr') + ' will list out your following people.\n'
- usage += s * 2 + green('fl') + ' will list out your follower.\n'
+ usage += s * 2 + green('show image 12') + ' will show image in ' + \
+ yellow('[id=12]') + 'in your OS\'s image viewer.\n'
+ usage += s * 2 + green('fl @dtvd88') + ' will follow ' + \
+ yellow('@dtvd88') + '.\n'
+ usage += s * 2 + green('ufl @dtvd88') + ' will unfollow ' + \
+ yellow('@dtvd88') + '.\n'
usage += s * 2 + green('h') + ' will show this help again.\n'
usage += s * 2 + green('c') + ' will clear the screen.\n'
usage += s * 2 + green('q') + ' will quit.\n'
"""
Exit all
"""
+ save_history()
os.system('rm -rf rainbow.db')
os.kill(g['stream_pid'], signal.SIGKILL)
sys.exit()
delete,
unfavorite,
search,
- friend,
- follower,
+ show,
+ follow,
+ unfollow,
help,
clear,
quit
['@'], # view
[], # tweet
[], # retweet
+ [], # favorite
[], # reply
[], # delete
+ [], # unfavorite
['#'], # search
- [], # friend
- [], # follower
+ ['image'], # show image
+ [], # follow
+ [], # unfollow
[], # help
[], # clear
[], # quit
]
))
init_interactive_shell(d)
+ read_history()
reset()
while True:
if g['prefix']: