Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
description = raw_input(light_magenta('Update description: ', rl=True))
try:
if name:
t.lists.update(
slug='-'.join(slug.split()),
owner_screen_name=g['original_name'],
name=name,
mode=mode,
description=description)
else:
t.lists.update(
slug=slug,
owner_screen_name=g['original_name'],
mode=mode,
description=description)
printNicely(green(slug + ' list is updated.'))
except:
debug_option()
printNicely(red('Oops something is wrong with Twitter :('))
word = [wo for wo in formater.split() if '#client' in wo][0]
delimiter = color_func(c['TWEET']['client'])(
client.join(word.split('#client')))
formater = delimiter.join(formater.split(word))
except:
pass
# Add spaces in begining of line if this is inside a notification
if noti:
formater = '\n '.join(formater.split('\n'))
# Reformat
if formater.startswith('\n'):
formater = formater[1:]
# Draw
printNicely(formater)
# Display Image
if c['IMAGE_ON_TERM'] and media_url:
for mu in media_url:
try:
response = requests.get(mu)
image_to_display(BytesIO(response.content))
except Exception:
printNicely(red('Sorry, image link is broken'))
source_user = cycle_color(source['name']) + \
color_func(c['NOTIFICATION']['source_nick'])(
' @' + source['screen_name'])
notify = color_func(c['NOTIFICATION']['notify'])(
'added you to a list')
date = parser.parse(created_at)
clock = fallback_humanize(date)
clock = color_func(c['NOTIFICATION']['clock'])(clock)
meta = c['NOTIFY_FORMAT']
meta = source_user.join(meta.split('#source_user'))
meta = notify.join(meta.split('#notify'))
meta = clock.join(meta.split('#clock'))
meta = emojize(meta)
# Output
printNicely('')
printNicely(meta)
print_list(target_object, noti=True)
except:
cmd = ''
# Lock the semaphore
c['lock'] = True
# Save cmd to global variable and call process
g['stuff'] = ' '.join(line.split()[1:])
# Check tweet length
# Process the command
process(cmd)()
# Not re-display
if cmd in ['switch', 't', 'rt', 'rep']:
g['prefix'] = False
else:
g['prefix'] = True
except EOFError:
printNicely('')
except TwitterHTTPError as e:
detail_twitter_error(e)
except Exception:
debug_option()
printNicely(red('OMG something is wrong with Twitter API right now.'))
finally:
# Release the semaphore lock
c['lock'] = False
source_user = cycle_color(source['name']) + \
color_func(c['NOTIFICATION']['source_nick'])(
' @' + source['screen_name'])
notify = color_func(c['NOTIFICATION']['notify'])(
'followed you')
date = parser.parse(created_at)
clock = fallback_humanize(date)
clock = color_func(c['NOTIFICATION']['clock'])(clock)
meta = c['NOTIFY_FORMAT']
meta = source_user.join(meta.split('#source_user'))
meta = notify.join(meta.split('#notify'))
meta = clock.join(meta.split('#clock'))
meta = emojize(meta)
# Output
printNicely('')
printNicely(meta)
def show_lists(t):
"""
List list
"""
rel = t.lists.list(screen_name=g['original_name'])
if rel:
print_list(rel)
else:
printNicely(light_magenta('You belong to no lists :)'))
rel = {}
next_cursor = -1
while next_cursor != 0:
m = t.lists.members(
slug=slug,
owner_screen_name=owner,
cursor=next_cursor,
include_entities=False)
for u in m['users']:
rel[u['name']] = '@' + u['screen_name']
next_cursor = m['next_cursor']
printNicely('All: ' + str(len(rel)) + ' members.')
for name in rel:
user = ' ' + cycle_color(name)
user += color_func(c['TWEET']['nick'])(' ' + rel[name] + ' ')
printNicely(user)
def reset():
"""
Reset prefix of line
"""
if g['reset']:
if c.get('USER_JSON_ERROR'):
printNicely(red('Your ~/.rainbow_config.json is messed up:'))
printNicely(red('>>> ' + c['USER_JSON_ERROR']))
printNicely('')
printNicely(magenta('Need tips ? Type "h" and hit Enter key!'))
g['reset'] = False
try:
printNicely(str(eval(g['cmd'])))
except Exception:
pass
def pause():
"""
Pause stream display
"""
g['pause'] = True
printNicely(green('Stream is paused'))
Add specific user to a list
"""
owner, slug = get_slug()
# Add
user_name = raw_input(
light_magenta(
'Give me name of the newbie: ',
rl=True))
if user_name.startswith('@'):
user_name = user_name[1:]
try:
t.lists.members.create(
slug=slug,
owner_screen_name=owner,
screen_name=user_name)
printNicely(green('Added.'))
except:
debug_option()
printNicely(light_magenta('I\'m sorry we can not add him/her.'))