From 26ab8ca27932aee65b9540c44ec1e328081e2ac8 Mon Sep 17 00:00:00 2001 From: Akamaru Date: Sun, 19 Apr 2015 21:17:53 +0200 Subject: [PATCH] moved credentials in an seperate file --- bot/bot.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/bot/bot.lua b/bot/bot.lua index f75c317..897a0e3 100644 --- a/bot/bot.lua +++ b/bot/bot.lua @@ -28,6 +28,7 @@ function on_binlog_replay_end() -- See plugins/ping.lua as an example for cron _config = load_config() + cred_data = load_cred() -- load plugins plugins = {} @@ -153,6 +154,19 @@ function load_config( ) return config end +function load_cred( ) + local cf = io.open('./data/credentials.lua', "r") + -- If credentials.lua doesnt exists + if not cf then + print ("Created new credentials file: data/credentials.lua") + create_cred() + else + cf:close() + end + local _file_cred = loadfile ("./data/credentials.lua")() + return _file_cred +end + -- Create a basic config.json file and saves it. function create_config( ) -- A simple config with basic plugins and ourserves as priviled user @@ -187,6 +201,26 @@ function create_config( ) print ('saved config into ./data/config.lua') end +function create_cred( ) + cred = { + bitly_access_token = "", + fb_access_token = "", + gender_apikey = "", + instagram_access_token = "", + lyricsnmusic_apikey = "", + neutrino_userid = "", + neutrino_apikey = "", + page2images_restkey = "", + soundcloud_client_id = "", + tw_consumer_key = "", + tw_consumer_secret = "", + tw_access_token = "", + tw_access_token_secret = "" + } + serialize_to_file(cred, './data/credentials.lua') + print ('saved credentials into ./data/credentials.lua') +end + function on_our_id (id) our_id = id end