diff options
Diffstat (limited to 'callback.py')
-rw-r--r-- | callback.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/callback.py b/callback.py index 4fe0540..aca8a90 100644 --- a/callback.py +++ b/callback.py | |||
@@ -3,7 +3,6 @@ from typing import cast, List | |||
3 | 3 | ||
4 | from telegram import ReplyKeyboardRemove | 4 | from telegram import ReplyKeyboardRemove |
5 | from telegram.constants import ChatAction | 5 | from telegram.constants import ChatAction |
6 | from telegram.error import BadRequest | ||
7 | from telegram.ext import CallbackContext | 6 | from telegram.ext import CallbackContext |
8 | 7 | ||
9 | from command import * | 8 | from command import * |
@@ -11,8 +10,9 @@ from dbstore.peewee_store import get_poi_by_fsq_id | |||
11 | from foursquare.poi import OSM_ENDPOINT | 10 | from foursquare.poi import OSM_ENDPOINT |
12 | from foursquare.poi import query_poi | 11 | from foursquare.poi import query_poi |
13 | from config import BOT_SCOPE | 12 | from config import BOT_SCOPE |
14 | from dbstore.peewee_store import User, db | 13 | from dbstore.peewee_store import User, db, TOOT_VISIBILITY_PRIVATE, TOOT_VISIBILITY_PUBLIC, TOOT_VISIBILITY_UNLISTED |
15 | import uuid | 14 | import uuid |
15 | from mastodon import Mastodon | ||
16 | 16 | ||
17 | 17 | ||
18 | def generate_uuid(): | 18 | def generate_uuid(): |
@@ -79,8 +79,6 @@ async def callback_generate_fedi_login_url(update: Update, context: ContextTypes | |||
79 | redirect_uris="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), | 79 | redirect_uris="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), |
80 | api_base_url=home_instance, | 80 | api_base_url=home_instance, |
81 | ) | 81 | ) |
82 | print("client_id: {}".format(client_id)) | ||
83 | print("client_secret: {}".format(client_secret)) | ||
84 | 82 | ||
85 | m = Mastodon(client_id=client_id, client_secret=client_secret, api_base_url=home_instance) | 83 | m = Mastodon(client_id=client_id, client_secret=client_secret, api_base_url=home_instance) |
86 | 84 | ||
@@ -115,7 +113,7 @@ async def callback_location_sharing(update: Update, context: ContextTypes.DEFAUL | |||
115 | 113 | ||
116 | poi = get_poi_by_fsq_id(context.user_data.get("fsq_id")) | 114 | poi = get_poi_by_fsq_id(context.user_data.get("fsq_id")) |
117 | content = generate_toot_text(poi["name"], poi["locality"], poi["region"], poi["latitude"], poi["longitude"]) | 115 | content = generate_toot_text(poi["name"], poi["locality"], poi["region"], poi["latitude"], poi["longitude"]) |
118 | status = get_mastodon_client(update.effective_user.id).status_post(content, visibility=DEFAULT_TOOT_VISIBILITY, media_ids=[]) | 116 | status = get_mastodon_client(update.effective_user.id).status_post(content, visibility=TOOT_VISIBILITY_PRIVATE, media_ids=[]) |
119 | 117 | ||
120 | context.user_data[KEY_TOOT_STATUS_ID] = status["id"] | 118 | context.user_data[KEY_TOOT_STATUS_ID] = status["id"] |
121 | context.user_data[KEY_TOOT_STATUS_CONTENT] = content | 119 | context.user_data[KEY_TOOT_STATUS_CONTENT] = content |
@@ -190,7 +188,7 @@ async def _process_location_selection(context: ContextTypes.DEFAULT_TYPE) -> int | |||
190 | else: | 188 | else: |
191 | content = generate_toot_text(poi_name, "", "", context.user_data.get("latitude"), context.user_data.get("longitude")) | 189 | content = generate_toot_text(poi_name, "", "", context.user_data.get("latitude"), context.user_data.get("longitude")) |
192 | 190 | ||
193 | status = get_mastodon_client(context.user_data["user_id"]).status_post(content, visibility=DEFAULT_TOOT_VISIBILITY, media_ids=[]) | 191 | status = get_mastodon_client(context.user_data["user_id"]).status_post(content, visibility=TOOT_VISIBILITY_PRIVATE, media_ids=[]) |
194 | 192 | ||
195 | context.user_data[KEY_TOOT_STATUS_ID] = status["id"] | 193 | context.user_data[KEY_TOOT_STATUS_ID] = status["id"] |
196 | context.user_data[KEY_TOOT_STATUS_CONTENT] = content | 194 | context.user_data[KEY_TOOT_STATUS_CONTENT] = content |