- # Personal stream
- elif target == 'mine':
- # Kill old process
- os.kill(g['stream_pid'], signal.SIGKILL)
- # Start new process
- p = Process(
- target=stream,
- args=(
- c['USER_DOMAIN'],
- args,
- g['original_name']))
- p.start()
- g['stream_pid'] = p.pid
- printNicely('')
- if args.filter:
- printNicely(cyan('Only: ' + str(args.filter)))
- if args.ignore:
- printNicely(red('Ignore: ' + str(args.ignore)))
- printNicely('')
- except:
- printNicely(red('Sorry I can\'t understand.'))
+def init(args):
+ """
+ Init function
+ """
+ # Handle Ctrl C
+ ctrl_c_handler = lambda signum, frame: quit()
+ signal.signal(signal.SIGINT, ctrl_c_handler)
+ # Upgrade notify
+ upgrade_center()
+ # Get name
+ t = Twitter(auth=authen())
+ credential = t.account.verify_credentials()
+ screen_name = '@' + credential['screen_name']
+ name = credential['name']
+ if not get_config('PREFIX'):
+ set_config('PREFIX', screen_name)
+ c['PREFIX'] = emojize(c['PREFIX'])
+ g['PREFIX'] = u2str(c['PREFIX'])
+ c['original_name'] = g['original_name'] = screen_name[1:]
+ g['full_name'] = name
+ g['decorated_name'] = lambda x: color_func(
+ c['DECORATED_NAME'])('[' + x + ']: ')
+ # Theme init
+ files = os.listdir(os.path.dirname(__file__) + '/colorset')
+ themes = [f.split('.')[0] for f in files if f.split('.')[-1] == 'json']
+ g['themes'] = themes
+ g['pause'] = False
+ g['message_threads'] = {}
+ # Events
+ g['events'] = []
+ # Startup cmd
+ g['cmd'] = ''
+ # Debug option default = True
+ g['debug'] = True
+ g['traceback'] = []
+ # Retweet of mine events
+ c['events'] = []
+ # Semaphore init
+ c['lock'] = False
+ # Init tweet dict and message dict
+ c['tweet_dict'] = []
+ c['message_dict'] = []
+ # Image on term
+ c['IMAGE_ON_TERM'] = args.image_on_term
+ set_config('IMAGE_ON_TERM', str(c['IMAGE_ON_TERM']))
+ # Mute dict
+ c['IGNORE_LIST'] += build_mute_dict()