diff options
author | clarkzjw <[email protected]> | 2023-02-21 13:00:07 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-21 13:00:07 -0800 |
commit | 431e8abcc4bf858e4ca945384a2f60702f1b5a4c (patch) | |
tree | a586f47e4a2d150a6961c6c914d0789fcf446d10 | |
parent | 6602a954788e26be63c00369f6bf72822752c84b (diff) | |
download | swarm2fediverse-431e8abcc4bf858e4ca945384a2f60702f1b5a4c.tar.gz |
make bot as a module
-rw-r--r-- | bot/__init__.py | 13 | ||||
-rw-r--r-- | bot/bot.py (renamed from bot.py) | 21 |
2 files changed, 16 insertions, 18 deletions
diff --git a/bot/__init__.py b/bot/__init__.py new file mode 100644 index 0000000..5e3c341 --- /dev/null +++ b/bot/__init__.py | |||
@@ -0,0 +1,13 @@ | |||
1 | from telegram import __version__ as TG_VER | ||
2 | |||
3 | try: | ||
4 | from telegram import __version_info__ | ||
5 | except ImportError: | ||
6 | __version_info__ = (0, 0, 0, 0, 0) # type: ignore[assignment] | ||
7 | |||
8 | if __version_info__ < (20, 0, 0, "alpha", 1): | ||
9 | raise RuntimeError( | ||
10 | f"This example is not compatible with your current PTB version {TG_VER}. To view the " | ||
11 | f"{TG_VER} version of this example, " | ||
12 | f"visit https://docs.python-telegram-bot.org/en/v{TG_VER}/examples.html" | ||
13 | ) | ||
@@ -5,28 +5,13 @@ | |||
5 | import logging | 5 | import logging |
6 | import io | 6 | import io |
7 | import telegram.constants | 7 | import telegram.constants |
8 | from telegram import __version__ as TG_VER | 8 | from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, ReplyKeyboardMarkup, KeyboardButton |
9 | 9 | from telegram.ext import Application, CallbackQueryHandler, CommandHandler, ContextTypes, MessageHandler, filters, ConversationHandler, CallbackContext | |
10 | try: | 10 | from ..config import BOT_TOKEN |
11 | from telegram import __version_info__ | ||
12 | except ImportError: | ||
13 | __version_info__ = (0, 0, 0, 0, 0) # type: ignore[assignment] | ||
14 | |||
15 | if __version_info__ < (20, 0, 0, "alpha", 1): | ||
16 | raise RuntimeError( | ||
17 | f"This example is not compatible with your current PTB version {TG_VER}. To view the " | ||
18 | f"{TG_VER} version of this example, " | ||
19 | f"visit https://docs.python-telegram-bot.org/en/v{TG_VER}/examples.html" | ||
20 | ) | ||
21 | from telegram import InlineKeyboardButton, InlineKeyboardMarkup | ||
22 | from telegram.ext import Application, CallbackQueryHandler, \ | ||
23 | CommandHandler, ContextTypes, MessageHandler, filters, ConversationHandler, CallbackContext | ||
24 | from config import BOT_TOKEN | ||
25 | from foursquare.poi import query_poi | 11 | from foursquare.poi import query_poi |
26 | from dbstore.dbm_store import get_loc | 12 | from dbstore.dbm_store import get_loc |
27 | from toot import mastodon_client | 13 | from toot import mastodon_client |
28 | from typing import TypedDict, List, cast | 14 | from typing import TypedDict, List, cast |
29 | from telegram import Update, ReplyKeyboardMarkup, KeyboardButton | ||
30 | 15 | ||
31 | scheduler = None | 16 | scheduler = None |
32 | PRIVACY, TOOT = map(chr, range(8, 10)) | 17 | PRIVACY, TOOT = map(chr, range(8, 10)) |