From 88ad58c3d3412162ffdeb96f49b789e7976cad07 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Mon, 20 Feb 2023 13:58:01 -0800 Subject: minor reformatting --- bot.py | 12 +++++++----- config.py | 1 + foursquare/query_poi.py | 7 +++++-- toot.py | 1 + 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/bot.py b/bot.py index 398e433..7679d7f 100644 --- a/bot.py +++ b/bot.py @@ -41,8 +41,8 @@ async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: hello = "Hello, this is `checkin.bot`. \n\n" \ "This is a Telegram bot with functionality similar to Foursquare Swarm, " \ "but check in and post your location to the Fediverse (Mastodon/Pleroma) instead of Twitter.\n\n" \ - "Aware of privacy concerns, this bot will not store your location data."\ - "*Be safe and cautious when sharing your real time location on the web.* \n\n"\ + "Aware of privacy concerns, this bot will not store your location data." \ + "*Be safe and cautious when sharing your real time location on the web.* \n\n" \ "Start using this bot by sharing your location using Telegram context menu to it." await update.message.reply_text(hello, parse_mode=telegram.constants.ParseMode.MARKDOWN) @@ -67,10 +67,12 @@ async def button(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: await query.answer() poi = get_loc(query.data) - mastodon_client.status_post(f"I'm at {poi['name']} in {poi['locality']}, {poi['region']}, \n[OSM]({poi['osm_url']})", - visibility="private") + status = mastodon_client.status_post( + f"I'm at {poi['name']} in {poi['locality']}, {poi['region']}, {poi['osm_url']}", + visibility="private") - await query.edit_message_text(text=f"Selected option: {poi}") + await query.edit_message_text(text=f"Selected place: {poi['name']}\nPosted to Mastodon: {status['url']}", + parse_mode=telegram.constants.ParseMode.MARKDOWN) async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: diff --git a/config.py b/config.py index a403db0..2469d0f 100644 --- a/config.py +++ b/config.py @@ -1,6 +1,7 @@ # https://docs.python.org/3/library/configparser.html import configparser + config = configparser.ConfigParser() config.read("config.ini") diff --git a/foursquare/query_poi.py b/foursquare/query_poi.py index efdd1b1..e2d5625 100644 --- a/foursquare/query_poi.py +++ b/foursquare/query_poi.py @@ -1,11 +1,14 @@ -import requests import json + +import requests + from config import FSQ_API_KEY -from dbstore.dbm_store import get_loc, store_loc +from dbstore.dbm_store import store_loc POI_API_ENDPOINT = "https://api.foursquare.com/v3/places/nearby?ll={}%2C{}" OSM_ENDPOINT = "https://www.openstreetmap.org/?mlat={}&mlon={}&zoom=15&layers=M" + def query_poi(latitude, longitude): locations = list() diff --git a/toot.py b/toot.py index f1db858..e1995fd 100644 --- a/toot.py +++ b/toot.py @@ -1,4 +1,5 @@ from mastodon import Mastodon + from config import TOOT_API_BASE_URL, TOOT_CLIENT_SECRET, TOOT_ACCESS_TOKEN, TOOT_CLIENT_ID ''' -- cgit v1.2.3