-
Notifications
You must be signed in to change notification settings - Fork 103
/
mongo.py
44 lines (38 loc) · 1.36 KB
/
mongo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#
# Copyright (C) 2023-2024 by YukkiOwner@Github, < https://github.com/YukkiOwner >.
#
# This file is part of < https://github.com/YukkiOwner/YukkiMusicBot > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/YukkiOwner/YukkiMusicBot/blob/master/LICENSE >
#
# All rights reserved.
#
from motor.motor_asyncio import AsyncIOMotorClient as _mongo_client_
from pymongo import MongoClient
from pyrogram import Client
import config
from ..logging import LOGGER
TEMP_MONGODB = "mongodb+srv://shikhar:shikhar@cluster0.6xzlh.mongodb.net/myFirstDatabase?retryWrites=true&w=majority"
if config.MONGO_DB_URI is None:
LOGGER(__name__).warning(
"No MONGO DB URL found.. Your Bot will work on Yukki's Database"
)
temp_client = Client(
name="Musikku",
api_id=config.API_ID,
api_hash=config.API_HASH,
bot_token=config.BOT_TOKEN,
)
temp_client.start()
info = temp_client.get_me()
username = info.username
temp_client.stop()
_mongo_async_ = _mongo_client_(TEMP_MONGODB)
_mongo_sync_ = MongoClient(TEMP_MONGODB)
mongodb = _mongo_async_[username]
pymongodb = _mongo_sync_[username]
else:
_mongo_async_ = _mongo_client_(config.MONGO_DB_URI)
_mongo_sync_ = MongoClient(config.MONGO_DB_URI)
mongodb = _mongo_async_.Musikku
pymongodb = _mongo_sync_.Musikku