diff options
-rw-r--r-- | bot.py | 12 | ||||
-rw-r--r-- | config.py | 1 | ||||
-rw-r--r-- | foursquare/query_poi.py | 7 | ||||
-rw-r--r-- | toot.py | 1 |
4 files changed, 14 insertions, 7 deletions
@@ -41,8 +41,8 @@ async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | |||
41 | hello = "Hello, this is `checkin.bot`. \n\n" \ | 41 | hello = "Hello, this is `checkin.bot`. \n\n" \ |
42 | "This is a Telegram bot with functionality similar to Foursquare Swarm, " \ | 42 | "This is a Telegram bot with functionality similar to Foursquare Swarm, " \ |
43 | "but check in and post your location to the Fediverse (Mastodon/Pleroma) instead of Twitter.\n\n" \ | 43 | "but check in and post your location to the Fediverse (Mastodon/Pleroma) instead of Twitter.\n\n" \ |
44 | "Aware of privacy concerns, this bot will not store your location data."\ | 44 | "Aware of privacy concerns, this bot will not store your location data." \ |
45 | "*Be safe and cautious when sharing your real time location on the web.* \n\n"\ | 45 | "*Be safe and cautious when sharing your real time location on the web.* \n\n" \ |
46 | "Start using this bot by sharing your location using Telegram context menu to it." | 46 | "Start using this bot by sharing your location using Telegram context menu to it." |
47 | 47 | ||
48 | await update.message.reply_text(hello, parse_mode=telegram.constants.ParseMode.MARKDOWN) | 48 | 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: | |||
67 | await query.answer() | 67 | await query.answer() |
68 | poi = get_loc(query.data) | 68 | poi = get_loc(query.data) |
69 | 69 | ||
70 | mastodon_client.status_post(f"I'm at {poi['name']} in {poi['locality']}, {poi['region']}, \n[OSM]({poi['osm_url']})", | 70 | status = mastodon_client.status_post( |
71 | visibility="private") | 71 | f"I'm at {poi['name']} in {poi['locality']}, {poi['region']}, {poi['osm_url']}", |
72 | visibility="private") | ||
72 | 73 | ||
73 | await query.edit_message_text(text=f"Selected option: {poi}") | 74 | await query.edit_message_text(text=f"Selected place: {poi['name']}\nPosted to Mastodon: {status['url']}", |
75 | parse_mode=telegram.constants.ParseMode.MARKDOWN) | ||
74 | 76 | ||
75 | 77 | ||
76 | async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | 78 | async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: |
@@ -1,6 +1,7 @@ | |||
1 | # https://docs.python.org/3/library/configparser.html | 1 | # https://docs.python.org/3/library/configparser.html |
2 | 2 | ||
3 | import configparser | 3 | import configparser |
4 | |||
4 | config = configparser.ConfigParser() | 5 | config = configparser.ConfigParser() |
5 | config.read("config.ini") | 6 | config.read("config.ini") |
6 | 7 | ||
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 @@ | |||
1 | import requests | ||
2 | import json | 1 | import json |
2 | |||
3 | import requests | ||
4 | |||
3 | from config import FSQ_API_KEY | 5 | from config import FSQ_API_KEY |
4 | from dbstore.dbm_store import get_loc, store_loc | 6 | from dbstore.dbm_store import store_loc |
5 | 7 | ||
6 | POI_API_ENDPOINT = "https://api.foursquare.com/v3/places/nearby?ll={}%2C{}" | 8 | POI_API_ENDPOINT = "https://api.foursquare.com/v3/places/nearby?ll={}%2C{}" |
7 | OSM_ENDPOINT = "https://www.openstreetmap.org/?mlat={}&mlon={}&zoom=15&layers=M" | 9 | OSM_ENDPOINT = "https://www.openstreetmap.org/?mlat={}&mlon={}&zoom=15&layers=M" |
8 | 10 | ||
11 | |||
9 | def query_poi(latitude, longitude): | 12 | def query_poi(latitude, longitude): |
10 | locations = list() | 13 | locations = list() |
11 | 14 | ||
@@ -1,4 +1,5 @@ | |||
1 | from mastodon import Mastodon | 1 | from mastodon import Mastodon |
2 | |||
2 | from config import TOOT_API_BASE_URL, TOOT_CLIENT_SECRET, TOOT_ACCESS_TOKEN, TOOT_CLIENT_ID | 3 | from config import TOOT_API_BASE_URL, TOOT_CLIENT_SECRET, TOOT_ACCESS_TOKEN, TOOT_CLIENT_ID |
3 | 4 | ||
4 | ''' | 5 | ''' |