diff options
author | clarkzjw <[email protected]> | 2023-02-23 01:09:50 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-23 12:07:32 -0800 |
commit | 6aafc4e506e2a9aa72955917f031241be4444c67 (patch) | |
tree | 1c52713792a47bfdae2bb99409f343825bdfc2c2 | |
parent | c30cba1bb04945a8000c6089d5dcd376e08b2133 (diff) | |
download | swarm2fediverse-6aafc4e506e2a9aa72955917f031241be4444c67.tar.gz |
bot: add command templates
-rw-r--r-- | bot.py | 12 | ||||
-rw-r--r-- | command.py | 18 | ||||
-rw-r--r-- | config.py | 1 | ||||
-rw-r--r-- | foursquare/poi.py | 2 | ||||
-rw-r--r-- | prompt/string.py | 38 |
5 files changed, 60 insertions, 11 deletions
@@ -39,7 +39,11 @@ from command import ( | |||
39 | start_command, | 39 | start_command, |
40 | fedi_login_command, | 40 | fedi_login_command, |
41 | cancel_command, | 41 | cancel_command, |
42 | help_command | 42 | help_command, |
43 | tos_command, | ||
44 | toggle_visibility_command, | ||
45 | logout_command, | ||
46 | list_command | ||
43 | ) | 47 | ) |
44 | from config import ( | 48 | from config import ( |
45 | FEDI_LOGIN, | 49 | FEDI_LOGIN, |
@@ -149,7 +153,11 @@ async def main() -> None: | |||
149 | ) | 153 | ) |
150 | 154 | ||
151 | # register handlers | 155 | # register handlers |
152 | application.add_handler(CommandHandler("help", help_command)) | 156 | application.add_handler(CommandHandler("tos", tos_command)) |
157 | application.add_handler(CommandHandler("vis", toggle_visibility_command)) | ||
158 | application.add_handler(CommandHandler("logout", logout_command)) | ||
159 | application.add_handler(CommandHandler("list", list_command)) | ||
160 | application.add_handler(CommandHandler("Help", help_command)) | ||
153 | application.add_handler(checkin_handler) | 161 | application.add_handler(checkin_handler) |
154 | application.add_handler(TypeHandler(type=FediLoginCallbackUpdate, callback=process_oauth_login_callback)) | 162 | application.add_handler(TypeHandler(type=FediLoginCallbackUpdate, callback=process_oauth_login_callback)) |
155 | 163 | ||
@@ -25,7 +25,23 @@ async def fedi_login_command(update: Update, context: ContextTypes.DEFAULT_TYPE) | |||
25 | 25 | ||
26 | 26 | ||
27 | async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | 27 | async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: |
28 | await update.message.reply_text(PROMPT_HELP) | 28 | await update.message.reply_text(PROMPT_HELP, parse_mode=ParseMode.MARKDOWN, reply_markup=MAIN_MENU) |
29 | |||
30 | |||
31 | async def tos_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | ||
32 | await update.message.reply_text(PROMPT_TOS, parse_mode=ParseMode.HTML, reply_markup=MAIN_MENU) | ||
33 | |||
34 | |||
35 | async def list_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | ||
36 | await update.message.reply_text(PROMPT_LIST, parse_mode=ParseMode.HTML, reply_markup=MAIN_MENU) | ||
37 | |||
38 | |||
39 | async def logout_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | ||
40 | await update.message.reply_text(PROMPT_LOGOUT, parse_mode=ParseMode.HTML, reply_markup=MAIN_MENU) | ||
41 | |||
42 | |||
43 | async def toggle_visibility_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | ||
44 | await update.message.reply_text(PROMPT_TOGGLE_VIS, parse_mode=ParseMode.HTML, reply_markup=MAIN_MENU) | ||
29 | 45 | ||
30 | 46 | ||
31 | async def cancel_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: | 47 | async def cancel_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: |
@@ -16,6 +16,7 @@ FEDI_LOGIN, WAIT_LOCATION, LOCATION_SEARCH_KEYWORD, LOCATION_CONFIRMATION, ADD_M | |||
16 | 16 | ||
17 | MAIN_MENU = ReplyKeyboardMarkup([ | 17 | MAIN_MENU = ReplyKeyboardMarkup([ |
18 | [KeyboardButton(text="Check-in here", request_location=True)], | 18 | [KeyboardButton(text="Check-in here", request_location=True)], |
19 | [KeyboardButton(text="/Help")] | ||
19 | ]) | 20 | ]) |
20 | 21 | ||
21 | SKIP_LOCATION_SEARCH = CALLBACK_SKIP | 22 | SKIP_LOCATION_SEARCH = CALLBACK_SKIP |
diff --git a/foursquare/poi.py b/foursquare/poi.py index ea3509f..39895b7 100644 --- a/foursquare/poi.py +++ b/foursquare/poi.py | |||
@@ -1,7 +1,5 @@ | |||
1 | import json | 1 | import json |
2 | |||
3 | import requests | 2 | import requests |
4 | |||
5 | from config import FSQ_API_KEY | 3 | from config import FSQ_API_KEY |
6 | from dbstore.peewee_store import create_or_update_poi | 4 | from dbstore.peewee_store import create_or_update_poi |
7 | 5 | ||
diff --git a/prompt/string.py b/prompt/string.py index a7bf0d1..eda0df8 100644 --- a/prompt/string.py +++ b/prompt/string.py | |||
@@ -1,9 +1,23 @@ | |||
1 | PROMPT_START = "Hello, this is `checkin.bot`. \n\n" \ | 1 | PROMPT_START = "Hello, this is `checkin.bot`. \n\n" \ |
2 | "This is a Telegram bot with functionality similar to Foursquare Swarm, " \ | 2 | "This is a Telegram bot with functionality similar to Foursquare Swarm, " \ |
3 | "but check in and post your location to the Fediverse (Mastodon/Pleroma) instead of Twitter.\n\n" \ | 3 | "but check in and post your location to the Fediverse (Mastodon/Pleroma) instead of Twitter.\n\n" \ |
4 | "Aware of privacy concerns, this bot will not store your location data." \ | 4 | "Aware of privacy concerns, this bot will not store your location data." \ |
5 | "*Be safe and cautious when sharing your real time location on the web.* \n\n" \ | 5 | "*Be safe and cautious when sharing your real time location on the web.* \n\n" \ |
6 | "Start using this bot by sharing your location using Telegram context menu to it." | 6 | "Start using this bot by sharing your location using Telegram context menu to it." |
7 | |||
8 | PROMPT_TOS = """ | ||
9 | By using this bot, you agree to the following terms of service:\n\n | ||
10 | |||
11 | <b>Data Collection</b> | ||
12 | |||
13 | <b>Server Logs</b> | ||
14 | |||
15 | <b>Server Locations</b> | ||
16 | |||
17 | <b>Data Sharing</b> | ||
18 | """ | ||
19 | |||
20 | |||
7 | PROMPT_FEDI_LOGIN_WHERE_IS_INSTANCE = "Where is your home instance in the Fediverse? (e.g. `https://mastodon.social`)" | 21 | PROMPT_FEDI_LOGIN_WHERE_IS_INSTANCE = "Where is your home instance in the Fediverse? (e.g. `https://mastodon.social`)" |
8 | PROMPT_FEDI_LOGIN = "Please login to your Fediverse account by clicking the link below:" | 22 | PROMPT_FEDI_LOGIN = "Please login to your Fediverse account by clicking the link below:" |
9 | PROMPT_CHOOSE_ACTION = "Use bot keyboard to choose an action" | 23 | PROMPT_CHOOSE_ACTION = "Use bot keyboard to choose an action" |
@@ -12,9 +26,21 @@ PROMPT_ADD_MEDIA = "You can continue adding photos, or press skip" | |||
12 | PROMPT_LOCATION_KEYWORD = "You can input location search keywords or press skip" | 26 | PROMPT_LOCATION_KEYWORD = "You can input location search keywords or press skip" |
13 | PROMPT_WAIT_LOCATION_CONFIRMATION_NO_NEARBY_POI = "No nearby places found. But you can input location name manually." | 27 | PROMPT_WAIT_LOCATION_CONFIRMATION_NO_NEARBY_POI = "No nearby places found. But you can input location name manually." |
14 | PROMPT_WAIT_LOCATION_CONFIRMATION = "Where are you?" | 28 | PROMPT_WAIT_LOCATION_CONFIRMATION = "Where are you?" |
15 | PROMPT_HELP = "Use /start to test this bot." | ||
16 | PROMPT_CANCELED = "Canceled" | 29 | PROMPT_CANCELED = "Canceled" |
17 | PROMPT_MAX_PHOTO_REACHED = "Cannot attach more than 4 medias, only first 4 will be posted" | 30 | PROMPT_MAX_PHOTO_REACHED = "Cannot attach more than 4 medias, only first 4 will be posted" |
18 | PROMPT_DONE = "Done" | 31 | PROMPT_DONE = "Done" |
32 | PROMPT_HELP = "Available commands:" \ | ||
33 | "\n`/login` - login to Fediverse account. " \ | ||
34 | "You can use this command to login to multiple Fediverse accounts" \ | ||
35 | "\n`/list` - list current linked Fediverse accounts" \ | ||
36 | "\n`/logout [number]` - logout from specified Fediverse account, default logout from all" \ | ||
37 | "\n`/vis public|private|unlisted [number]` - " \ | ||
38 | "toggle visibility of your checkins on specified instances, default=private" \ | ||
39 | "\n`/tos` - show ToS message" \ | ||
40 | "\n`/cancel` - cancel current operation during checkins" | ||
41 | |||
42 | PROMPT_LIST = "List all linked Fediverse accounts" | ||
43 | PROMPT_LOGOUT = "Choose Fediverse account to logout" | ||
44 | PROMPT_TOGGLE_VIS = "Choose visibility of your checkins on Fediverse" | ||
19 | 45 | ||
20 | CALLBACK_SKIP = "Skip" | 46 | CALLBACK_SKIP = "Skip" |