"""
Init function
"""
+ # Handle Ctrl C
+ ctrl_c_handler = lambda signum, frame: quit()
+ signal.signal(signal.SIGINT, ctrl_c_handler)
# Get name
t = Twitter(auth=authen())
name = '@' + t.account.verify_credentials()['screen_name']
"""
Exit all
"""
- save_history()
- os.system('rm -rf rainbow.db')
- os.kill(g['stream_pid'], signal.SIGKILL)
+ try:
+ save_history()
+ os.system('rm -rf rainbow.db')
+ os.kill(g['stream_pid'], signal.SIGKILL)
+ printNicely(green('See you next time :)'))
+ except:
+ pass
sys.exit()
g['cmd'] = cmd
try:
# Lock the semaphore
- db.semaphore_update_flag(True)
+ db.semaphore_update_lock(True)
# Save cmd to global variable and call process
g['stuff'] = ' '.join(line.split()[1:])
# Process the command
else:
g['prefix'] = True
# Release the semaphore lock
- db.semaphore_update_flag(False)
+ db.semaphore_update_lock(False)
except Exception:
printNicely(red('OMG something is wrong with Twitter right now.'))
ig=args.ignore,
)
elif tweet.get('direct_message'):
- print_message(tweet['direct_message'])
+ print_message(tweet['direct_message'],check_semaphore=True)
except TwitterHTTPError:
printNicely('')
printNicely(
except TwitterHTTPError:
printNicely('')
printNicely(
- magenta("Something wrong with Twitter Oauth right now :("))
- printNicely(
- magenta("Please delete ~/.rainbow_oauth and try again."))
+ magenta("We have maximum connection problem with twitter'stream API right now :("))
+ printNicely(magenta("Let's try again later."))
save_history()
os.system('rm -rf rainbow.db')
sys.exit()