sender='killebrew_bot') if __name__ == '__main__': # load json config try: with open('config.json') as json_config: config = json.load(json_config) except Exception: sys.exit('Failed to open config.json') else: db_name = config['db_name'] table_name = config['table_name'] player_list = config['player_list'] super_user = string.capwords(config['super_user']) hipchat = Hipster(config['api_key']) room_id = config['room_id'] # connect to db connection = get_mysql_connection(db_name) # get users in hipchat room while True: response = hipchat.get_users_list() if response['status'] == 200: users = response['data']['users'] break else: sleep(5) continue
return str(picked) if __name__ == "__main__": try: with open('config.json') as config_file: config = json.load(config_file) api_key = config['api_key'] room_id = config['room_id'] debug = config.get('debug') except Exception: sys.exit('Unable to load config file') hipchat = Hipster(api_key) bot_name = 'Support Bot' last_date = None if debug: room_id = 1447044 # send to the BotTest room at = "" # remove mention from the message else: at = "@" first_time = True while not stopped: try: messages = hipchat.get_messages(room_id=room_id, date='recent') for message in messages['data']['messages']: