aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--callback.py10
-rw-r--r--command.py1
-rw-r--r--config.py1
-rw-r--r--dbstore/peewee_store.py6
-rw-r--r--foursquare/poi.py1
5 files changed, 10 insertions, 9 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
4from telegram import ReplyKeyboardRemove 4from telegram import ReplyKeyboardRemove
5from telegram.constants import ChatAction 5from telegram.constants import ChatAction
6from telegram.error import BadRequest
7from telegram.ext import CallbackContext 6from telegram.ext import CallbackContext
8 7
9from command import * 8from command import *
@@ -11,8 +10,9 @@ from dbstore.peewee_store import get_poi_by_fsq_id
11from foursquare.poi import OSM_ENDPOINT 10from foursquare.poi import OSM_ENDPOINT
12from foursquare.poi import query_poi 11from foursquare.poi import query_poi
13from config import BOT_SCOPE 12from config import BOT_SCOPE
14from dbstore.peewee_store import User, db 13from dbstore.peewee_store import User, db, TOOT_VISIBILITY_PRIVATE, TOOT_VISIBILITY_PUBLIC, TOOT_VISIBILITY_UNLISTED
15import uuid 14import uuid
15from mastodon import Mastodon
16 16
17 17
18def generate_uuid(): 18def 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
diff --git a/command.py b/command.py
index e45a2e2..901b792 100644
--- a/command.py
+++ b/command.py
@@ -4,7 +4,6 @@ from telegram.error import BadRequest
4from telegram.ext import ContextTypes, ConversationHandler 4from telegram.ext import ContextTypes, ConversationHandler
5 5
6from config import * 6from config import *
7from mastodon import Mastodon
8 7
9 8
10async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: 9async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
diff --git a/config.py b/config.py
index 3b5767b..9e72598 100644
--- a/config.py
+++ b/config.py
@@ -16,7 +16,6 @@ TOOT_CLIENT_ID = config["TOOT"]["CLIENT_ID"]
16TOOT_CLIENT_SECRET = config["TOOT"]["CLIENT_SECRET"] 16TOOT_CLIENT_SECRET = config["TOOT"]["CLIENT_SECRET"]
17TOOT_ACCESS_TOKEN = config["TOOT"]["ACCESS_TOKEN"] 17TOOT_ACCESS_TOKEN = config["TOOT"]["ACCESS_TOKEN"]
18 18
19DEFAULT_TOOT_VISIBILITY = "private"
20 19
21MEDIA_GROUP_TIMEOUT = 3 20MEDIA_GROUP_TIMEOUT = 3
22 21
diff --git a/dbstore/peewee_store.py b/dbstore/peewee_store.py
index 37b8c01..00897d7 100644
--- a/dbstore/peewee_store.py
+++ b/dbstore/peewee_store.py
@@ -1,5 +1,10 @@
1from peewee import * 1from peewee import *
2 2
3TOOT_VISIBILITY_PUBLIC = "public"
4TOOT_VISIBILITY_UNLISTED = "unlisted"
5TOOT_VISIBILITY_PRIVATE = "private"
6
7
3db = SqliteDatabase("checkinbot.db") 8db = SqliteDatabase("checkinbot.db")
4db.connect(reuse_if_open=True) 9db.connect(reuse_if_open=True)
5 10
@@ -16,6 +21,7 @@ class User(BaseModel):
16 state = CharField(max_length=128) 21 state = CharField(max_length=128)
17 client_id = CharField(max_length=128) 22 client_id = CharField(max_length=128)
18 client_secret = CharField(max_length=128) 23 client_secret = CharField(max_length=128)
24 toot_visibility = CharField(max_length=128, default=TOOT_VISIBILITY_PRIVATE)
19 25
20 26
21class Location(BaseModel): 27class Location(BaseModel):
diff --git a/foursquare/poi.py b/foursquare/poi.py
index 45b4fa9..4ff11fb 100644
--- a/foursquare/poi.py
+++ b/foursquare/poi.py
@@ -19,7 +19,6 @@ def query_poi(search, latitude, longitude):
19 locations = list() 19 locations = list()
20 20
21 url = POI_SEARCH_API_ENDPOINT.format(search, latitude, longitude) 21 url = POI_SEARCH_API_ENDPOINT.format(search, latitude, longitude)
22 print(url)
23 response = requests.get(url, headers=headers) 22 response = requests.get(url, headers=headers)
24 23
25 for poi in json.loads(response.text)["results"]: 24 for poi in json.loads(response.text)["results"]:
Powered by cgit v1.2.3 (git 2.41.0)