Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
405 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,4 +130,5 @@ dmypy.json | |
|
||
# Custom | ||
.vscode | ||
.idea | ||
test_results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
import asyncio | ||
|
||
import motor.core | ||
from motor.motor_asyncio import AsyncIOMotorClient | ||
from umongo.frameworks import MotorAsyncIOInstance | ||
|
||
from telathbot.config import get_settings | ||
from telathbot.constants import METADATA_COLLECTION, TELATHBOT_DB, VERSION | ||
from telathbot.logger import LOGGER | ||
|
||
|
||
async def initialize(): | ||
config = get_settings() | ||
database = AsyncIOMotorClient(config.telathbot_db_url) | ||
metadata_collection = database[TELATHBOT_DB][METADATA_COLLECTION] | ||
from telathbot.constants import TELATHBOT_DB | ||
|
||
if await metadata_collection.count_documents({}) == 0: | ||
metadata = {"type": "metadata", "appVersion": VERSION, "lastPostId": 0} | ||
CLIENT = AsyncIOMotorClient(get_settings().telathbot_db_url) | ||
CLIENT.get_io_loop = asyncio.get_running_loop | ||
DB = CLIENT[TELATHBOT_DB] | ||
|
||
await metadata_collection.insert_one(metadata) | ||
LOGGER.info("No metadata found. Initializing!") | ||
else: | ||
LOGGER.info("Metadata found.") | ||
UMONGO = MotorAsyncIOInstance(DB) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.