Add userbot as optional [test]

This commit is contained in:
yasirarism 2023-05-16 05:05:40 +00:00 committed by GitHub
parent bddcef7134
commit 802c8f013e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 82 additions and 15 deletions

View file

@ -59,13 +59,43 @@ You can check demo this repo in this bot [MissKatyPyro](https://t.me/MissKatyRoB
* `API_ID`: Get this value from [telegram.org](https://my.telegram.org/apps)
* `API_HASH`: Get this value from [telegram.org](https://my.telegram.org/apps)
* `DATABASE_URI`: [mongoDB](https://www.mongodb.com) URI. Get this value from [mongoDB](https://www.mongodb.com). For more help watch this [video](https://youtu.be/1G1XwEOnxxo)
* `DATABASE_NAME`: Name of the database in [mongoDB](https://www.mongodb.com). For more help watch this [video](https://youtu.be/1G1XwEOnxxo)
* `LOG_CHANNEL` : A channel to log the activities of bot. Make sure bot is an admin in the channel.
* `USER_SESSION` : Session string for Userbot.
### Optional Variables
Check by yourself in config files.
## Deploy (Must Use Docker to Run This Bot, since i had make it built in all requirements)
### Optional Variables
* `USER_SESSION` : Session string for Userbot.
* `DATABASE_NAME`: Name of the database in MongoDB
* `COMMAND_HANDLER`: List of handler bot command splitted by space. Ex: `. !` > so bot will respond with `.cmd` or `!cmd`
* `SUDO`: User ID that have access to bot, split by space
* `OPENAI_API`: Get it from OpenAI Web
* `CURRENCY_API`: Get API Key from https://app.exchangerate-api.com/sign-up
## Deploy (Recommended using Docker/Docker Compose)
#### Build And Run Using Legacy Method
- Make sure minimum python version is 3.8 to prevent some errors. Check it with this command:
```
python3 --version
```
- Install all dependency that needed bot to run. *(need root access, you can skip this if your server didn't have root access but some plugins will not work)*
```
apt update -y & apt install libjpeg-dev zlib1g-dev libwebp-dev python3-pip python3-lxml git wget curl ffmpeg locales tzdata neofetch mediainfo speedtest-cli -y
```
- Install requirements.txt, if using python 3.11, you need pass `--break-system-packages` parameter.
*Python < 3.10*
```
pip3 install -r requirements.txt
```
*Python 3.11*
```
pip3 install -r requirements.txt --break-system-packages
```
- Setting your config.env or via environment. Make sure you fill all required env/
- Run Bot
```
bash start.sh
```
#### Build And Run Using Docker
- Start Docker daemon (Skip if already running):
```

View file

@ -51,10 +51,11 @@ jobstores = {"default": MongoDBJobStore(client=pymonclient, database="MissKatyDB
scheduler = AsyncIOScheduler(jobstores=jobstores, timezone=TZ)
app.start()
user.start()
if USER_SESSION:
user.start()
UBOT_ID = user.me.id
UBOT_NAME = user.me.first_name
UBOT_USERNAME = user.me.username
BOT_ID = app.me.id
BOT_NAME = app.me.first_name
BOT_USERNAME = app.me.username
UBOT_ID = user.me.id
UBOT_NAME = user.me.first_name
UBOT_USERNAME = user.me.username

View file

@ -24,7 +24,7 @@ from misskaty import (
scheduler
)
from misskaty.plugins import ALL_MODULES
from misskaty.vars import SUDO
from misskaty.vars import SUDO, USER_SESSION
from utils import auto_clean
LOGGER = getLogger(__name__)
@ -59,10 +59,16 @@ async def start_bot():
try:
LOGGER.info("[INFO]: SENDING ONLINE STATUS")
for i in SUDO:
await app.send_message(
i,
f"USERBOT AND BOT STARTED with Pyrogram v{__version__}..\nUserBot: {UBOT_NAME}\nBot: {BOT_NAME}\n\nwith Pyrogram v{__version__} (Layer {layer}) started on @{BOT_USERNAME}.\n\n<code>{bot_modules}</code>",
)
if USER_SESSION:
await app.send_message(
i,
f"USERBOT AND BOT STARTED with Pyrogram v{__version__}..\nUserBot: {UBOT_NAME}\nBot: {BOT_NAME}\n\nwith Pyrogram v{__version__} (Layer {layer}) started on @{BOT_USERNAME}.\n\n<code>{bot_modules}</code>",
)
else:
await app.send_message(
i,
f"BOT STARTED with Pyrogram v{__version__}..\nBot: {BOT_NAME}\n\nwith Pyrogram v{__version__} (Layer {layer}) started on @{BOT_USERNAME}.\n\n<code>{bot_modules}</code>",
)
except Exception as e:
LOGGER.error(str(e))
scheduler.start()

View file

@ -22,7 +22,7 @@ from psutil import virtual_memory
from pyrogram import enums, filters, Client, __version__ as pyrover
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
from pyrogram.raw.types import UpdateBotStopped
from pykeyboard import InlineKeyboard
from pykeyboard import InlineKeyboard, InlineButton
from misskaty import app, user, botStartTime, misskaty_version, BOT_NAME
from misskaty.helper.http import http

30
requirements.txt Normal file
View file

@ -0,0 +1,30 @@
emoji
git+https://github.com/yasirarism/pyrofork
tgcrypto
pymongo
python-dotenv
motor[srv]>=3.1.2
requests
bs4
aiohttp
chevron
gTTS
regex
apscheduler
pytz
pykeyboard
pySmartDL
psutil
python-dateutil
telegraph
hachoir
Pillow>=9.5.0
httpx[http2]
git+https://github.com/yasirarism/vcsi
git+https://github.com/yasirarism/iytdl
deep-translator
telethon
pyrate_limiter
cachetools
cfscrape
openai