aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'callback.py')
-rw-r--r--callback.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/callback.py b/callback.py
index d2f3ae7..c7cb60c 100644
--- a/callback.py
+++ b/callback.py
@@ -10,7 +10,10 @@ from command import *
10from dbstore.dbm_store import get_loc 10from dbstore.dbm_store import get_loc
11from foursquare.poi import OSM_ENDPOINT 11from foursquare.poi import OSM_ENDPOINT
12from foursquare.poi import query_poi 12from foursquare.poi import query_poi
13from toot import mastodon_client 13# from toot import mastodon_client
14from config import BOT_SCOPE
15
16mastodon_client = None
14 17
15 18
16def generate_toot_text(poi_name, poi_locality, poi_region, poi_lat, poi_lon): 19def generate_toot_text(poi_name, poi_locality, poi_region, poi_lat, poi_lon):
@@ -59,16 +62,21 @@ async def process_media_group(context: CallbackContext):
59 62
60async def callback_generate_fedi_login_url(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: 63async def callback_generate_fedi_login_url(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
61 # generate fedi OAuth login url 64 # generate fedi OAuth login url
65 global mastodon_client
66
62 home_instance = update.effective_message.text 67 home_instance = update.effective_message.text
63 client_id, client_secret = Mastodon.create_app( 68 client_id, client_secret = Mastodon.create_app(
64 "Checkin.bot", 69 "Checkin.bot",
65 scopes=['write:media', 'write:statuses'], 70 scopes=BOT_SCOPE,
66 redirect_uris="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), 71 redirect_uris="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL),
67 api_base_url=home_instance, 72 api_base_url=home_instance,
68 ) 73 )
69 mastodon_client = Mastodon(client_id=client_id, client_secret=client_secret, api_base_url=home_instance) 74 m = Mastodon(client_id=client_id, client_secret=client_secret, api_base_url=home_instance)
70 oauth_url = mastodon_client.auth_request_url(redirect_uris="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), 75
71 scopes=['write:media', 'write:statuses'], 76 # TODO
77 # generate random string as OAuth state
78 oauth_url = m.auth_request_url(redirect_uris="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL),
79 scopes=BOT_SCOPE,
72 state=update.effective_user.id) 80 state=update.effective_user.id)
73 81
74 await update.message.reply_text(PROMPT_FEDI_LOGIN, 82 await update.message.reply_text(PROMPT_FEDI_LOGIN,
Powered by cgit v1.2.3 (git 2.41.0)