From b41ed0201c80e3de0078dbacd766f5ef62819363 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Mon, 20 Feb 2023 01:13:52 -0800 Subject: add python ini config example --- config.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 config.py (limited to 'config.py') diff --git a/config.py b/config.py new file mode 100644 index 0000000..7f8e2f0 --- /dev/null +++ b/config.py @@ -0,0 +1,28 @@ +# https://docs.python.org/3/library/configparser.html + +# import configparser +# config = configparser.ConfigParser() +# config['DEFAULT'] = {'ServerAliveInterval': '45', +# 'Compression': 'yes', +# 'CompressionLevel': '9'} +# config['forge.example'] = {} +# config['forge.example']['User'] = 'hg' +# config['topsecret.server.example'] = {} +# topsecret = config['topsecret.server.example'] +# topsecret['Port'] = '50022' # mutates the parser +# topsecret['ForwardX11'] = 'no' # same here +# config['DEFAULT']['ForwardX11'] = 'yes' +# with open('example.ini', 'w') as configfile: +# config.write(configfile) + +# config = configparser.ConfigParser() +# config.sections() +# config.read('example.ini') +# config.sections() +# topsecret = config['topsecret.server.example'] +# topsecret['ForwardX11'] +# topsecret['Port'] +# for key in config['forge.example']: +# print(key) + +# config['forge.example']['ForwardX11'] -- cgit v1.2.3 From 3a230798be1bc63b363cf75b8b1cae3a508cca84 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Mon, 20 Feb 2023 01:55:20 -0800 Subject: 4sq: add query poi example --- config.py | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) (limited to 'config.py') diff --git a/config.py b/config.py index 7f8e2f0..377a6c3 100644 --- a/config.py +++ b/config.py @@ -1,28 +1,8 @@ # https://docs.python.org/3/library/configparser.html -# import configparser -# config = configparser.ConfigParser() -# config['DEFAULT'] = {'ServerAliveInterval': '45', -# 'Compression': 'yes', -# 'CompressionLevel': '9'} -# config['forge.example'] = {} -# config['forge.example']['User'] = 'hg' -# config['topsecret.server.example'] = {} -# topsecret = config['topsecret.server.example'] -# topsecret['Port'] = '50022' # mutates the parser -# topsecret['ForwardX11'] = 'no' # same here -# config['DEFAULT']['ForwardX11'] = 'yes' -# with open('example.ini', 'w') as configfile: -# config.write(configfile) +import configparser +config = configparser.ConfigParser() +config.read("config.ini") -# config = configparser.ConfigParser() -# config.sections() -# config.read('example.ini') -# config.sections() -# topsecret = config['topsecret.server.example'] -# topsecret['ForwardX11'] -# topsecret['Port'] -# for key in config['forge.example']: -# print(key) - -# config['forge.example']['ForwardX11'] +BOT_TOKEN = config["DEFAULT"]["BOT_TOKEN"] +FSQ_API_KEY = config["DEFAULT"]["FOURSQUARE_API_KEY"] -- cgit v1.2.3 From f7f99f41e768e6740adbf2ee708488b29fe6265a Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Mon, 20 Feb 2023 13:47:26 -0800 Subject: implemented basic functions: - send a location from Telegram to bot - query a list (7) of POIs from Foursquare - send user inline keyboard button to choose a location - post toot status update to Mastodon with a link to OSM - store previously seen locations in local db --- config.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'config.py') diff --git a/config.py b/config.py index 377a6c3..a403db0 100644 --- a/config.py +++ b/config.py @@ -6,3 +6,8 @@ config.read("config.ini") BOT_TOKEN = config["DEFAULT"]["BOT_TOKEN"] FSQ_API_KEY = config["DEFAULT"]["FOURSQUARE_API_KEY"] + +TOOT_API_BASE_URL = config["TOOT"]["API_BASE_URL"] +TOOT_CLIENT_ID = config["TOOT"]["CLIENT_ID"] +TOOT_CLIENT_SECRET = config["TOOT"]["CLIENT_SECRET"] +TOOT_ACCESS_TOKEN = config["TOOT"]["ACCESS_TOKEN"] -- cgit v1.2.3