'ufav',
's',
'show',
+ 'ls',
'fl',
'ufl',
'h',
]
-def draw(t, imgflg = 0, keyword=None, fil=[], ig=[]):
+def draw(t, iot=False, keyword=None, fil=[], ig=[]):
"""
Draw the rainbow
"""
printNicely(line3)
# Display Image
- if imgflg and media_url:
+ if iot and media_url:
for mu in media_url:
response = requests.get(mu)
image_to_display(StringIO(response.content))
'--ignore',
help='Ignore specific screen_name.')
parser.add_argument(
- '-img',
- '--image',
- help='Display all photo on terminal.')
+ '-iot',
+ '--image-on-term',
+ action='store_true',
+ help='Display all image on terminal.')
return parser.parse_args()
if g['stuff'].isdigit():
num = g['stuff']
for tweet in reversed(t.statuses.home_timeline(count=num)):
- draw(t=tweet, imgflg=g['image'])
+ draw(t=tweet, iot=g['iot'])
printNicely('')
except:
num = HOME_TWEET_NUM
for tweet in reversed(t.statuses.user_timeline(count=num, screen_name=user[1:])):
- draw(t=tweet, imgflg=g['image'])
+ draw(t=tweet, iot=g['iot'])
printNicely('')
else:
printNicely(red('A name should begin with a \'@\''))
tid = db.rainbow_query(id)[0].tweet_id
t.favorites.create(_id=tid, include_entities=False)
printNicely(green('Favorited.'))
- draw(t.statuses.show(id=tid), imgflg=g['image'])
+ draw(t.statuses.show(id=tid), iot=g['iot'])
except:
printNicely(red('Omg some syntax is wrong.'))
tid = db.rainbow_query(id)[0].tweet_id
t.favorites.destroy(_id=tid)
printNicely(green('Okay it\'s unfavorited.'))
- draw(t.statuses.show(id=tid), imgflg=g['image'])
+ draw(t.statuses.show(id=tid), iot=g['iot'])
except:
printNicely(red('Sorry I can\'t unfavorite this tweet for you.'))
printNicely('Newest tweets:')
for i in reversed(xrange(SEARCH_MAX_RECORD)):
draw(t=rel[i],
- imgflg=g['image'],
- keyword=g['stuff'].strip()[1:])
+ iot=g['iot'],
+ keyword=g['stuff'].strip()[1:])
printNicely('')
else:
printNicely(magenta('I\'m afraid there is no result'))
printNicely(red('Sorry I can\'t show this image.'))
+def list():
+ """
+ List friends for followers
+ """
+ t = Twitter(auth=authen())
+ try:
+ target = g['stuff'].split()[0]
+ d = {'fl': 'followers', 'fr': 'friends'}
+ next_cursor = -1
+ rel = {}
+ # Cursor loop
+ while next_cursor != 0:
+ list = getattr(t, d[target]).list(screen_name=g['original_name'],
+ cursor=next_cursor,
+ skip_status=True,
+ include_entities=False,
+ )
+ for u in list['users']:
+ rel[u['name']] = '@' + u['screen_name']
+ next_cursor = list['next_cursor']
+ # Print out result
+ printNicely('All: ' + str(len(rel)) + ' people.')
+ for name in rel:
+ user = ' ' + cycle_color(name) + grey(' ' + rel[name] + ' ')
+ printNicely(user)
+ except:
+ printNicely(red('Omg some syntax is wrong.'))
+
+
def follow():
"""
Follow a user
t = Twitter(auth=authen())
screen_name = g['stuff'].split()[0]
if screen_name[0] == '@':
- try :
- t.friendships.create(screen_name=screen_name[1:],follow=True)
+ 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.'))
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)
+ 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.'))
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('show image 12') + ' will show image in ' + \
- yellow('[id=12]') + 'in your OS\'s image viewer.\n'
+ usage += s * 2 + green('show image 12') + ' will show image in tweet with ' + \
+ yellow('[id=12]') + ' in your OS\'s image viewer.\n'
+ usage += s * 2 + \
+ green('ls fl') + \
+ ' will list all followers (people who is following you).\n'
+ usage += s * 2 + \
+ green('ls fr') + \
+ ' will list all friends (people who you are following).\n'
usage += s * 2 + green('fl @dtvd88') + ' will follow ' + \
yellow('@dtvd88') + '.\n'
usage += s * 2 + green('ufl @dtvd88') + ' will unfollow ' + \
unfavorite,
search,
show,
+ list,
follow,
unfollow,
help,
d = dict(zip(
cmdset,
[
- ['public #', 'mine'], # switch
+ ['public', 'mine'], # switch
[], # home
['@'], # view
[], # tweet
[], # unfavorite
['#'], # search
['image'], # show image
- [], # follow
- [], # unfollow
+ ['fl', 'fr'], # show image
+ ['@'], # follow
+ ['@'], # unfollow
[], # help
[], # clear
[], # quit
elif tweet.get('text'):
draw(
t=tweet,
- imgflg=args.image,
+ iot=args.image_on_term,
keyword=args.track_keywords,
fil=args.filter,
ig=args.ignore,
- )
+ )
def fly():
g['reset'] = True
g['prefix'] = True
g['stream_pid'] = p.pid
- g['image'] = args.image
- listen()
\ No newline at end of file
+ g['iot'] = args.image_on_term
+ listen()