예제 #1
0
 def __init__(self, state):
     self.state = state
     self.cal_check = CalendarCheck(self.state)
     self.config = ConfigControls()
     '''Config'''
     self.c = self.get_config()
     self.RING_TIME_THRESHOLD = 15  #[seconds]
예제 #2
0
파일: state.py 프로젝트: esdandreu/WakePi
 def __init__(self, bot):
     '''Config'''
     self.max_msg_line_length = 29
     self.max_reply_line_length = 28
     '''Initializations'''
     self.config = ConfigControls()
     self.mopidy = MopidyControls(self)
     self.mopidy.refresh_token()
     self.alarm = AlarmControls(self)
     self.cal_check = CalendarCheck(self)
     self.font = AsciiFont()
     self.bot = bot
     self.default_volume = self.get_default_control("volume")
     self.mopidy.set_volume_sys(self.default_volume)
     self.set_reply_text('')
     '''General variables'''
     self.state = 'music'
     self.dashboard_type = 'music'
     self.keyboard_type = 'home home'
     self.music_status = self.mopidy.get_status()
     self.last_dash_msg = [False]
     self.last_reply_msg = [False]
     self.chat_id_list = []
     self.chat_password = self.get_password()
     self.auto_refresh_enabled = True
     self.week_events = [[], [], [], [], [], [], []]
     self.set_alarm_day = 0
     self.snooze_counts = 0
     self.set_config_name = ' '
     self.alarm_to_edit = [['manual', 'disabled'],
                           datetime.time(hour=0, minute=0)]
     '''Search stored variables'''
     self.search_type = False
     self.search_query = False
     self.options_list = False
     self.uri_list = False
     self.uri = False
예제 #3
0
 def __init__(self, state):
     self.state = state
     self.config = ConfigControls()
예제 #4
0
 def __init__(self, state):
     self.state = state
     self.config = ConfigControls()
     self.MAX_SEARCH_RESULTS = 20
     self.spotipy_VERSION = spotipy.VERSION
예제 #5
0
now = datetime.datetime.utcnow()
file_log = now.strftime('%d_%m_%y %H_%M') + '.log'
logger = logging.getLogger('WakePi')
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(file_log)
fh.setLevel(logging.INFO)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('[%(levelname)7s] %(asctime)s: %(message)s')
fh.setFormatter(formatter)
ch.setFormatter(formatter)
logger.addHandler(fh)
logger.addHandler(ch)
logger.info('Start initialization')
'''Initialize modules'''
config = ConfigControls()
bot = telepot.Bot(get_bot_token())
state = State(bot)
cp = CommandProcess(state, bot)
mopidy = MopidyControls(state)
logger.info('Spotipy version ' + mopidy.spotipy_VERSION)
cal_check = CalendarCheck(state)
alarm = AlarmControls(state)
MessageLoop(bot, {
    'chat': on_chat_message,
    'callback_query': on_callback_query
}).run_as_thread()
state.week_events = state.cal_check.get_week_events_local_times()
alarm.set_auto_alarms(state.week_events)
'''Parallel process'''
if __name__ == "__main__":