Skip to content

Commit

Permalink
ADD: assets, markdown directory
Browse files Browse the repository at this point in the history
RELEASE: 1.1.0
  • Loading branch information
BaggerFast committed Sep 21, 2022
1 parent 1205622 commit 80d4ca5
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 18 deletions.
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
# AdvancedUserTelegramBot
# PyConsoleMenu
![Language](https://img.shields.io/badge/Language-Python3.10+-blue.svg?style=flat)
[![BUILD-STATUS](https://github.com/BaggerFast/AdvancedUserTelegramBot/workflows/CI/badge.svg)](https://github.com/BaggerFast/AdvancedUserTelegramBot/actions)

This is a telegram bot that creates a user bot for each user.
The user bot allows you to use custom animations in any chat.
Animations are divided into paid and free


--------

## Example:
[<img src="assets/preview.gif" width="639" height="235.5" alt="preview"/>](assets/preview.gif)

## Tech Stack 💻

- **Languages:**
- Python 3.10
- **Telegram:**
- [Aiogram](https://docs.aiogram.dev/en/latest/) - for main bot
- [Pyrogram](https://docs.pyrogram.org/) - for user bot
- **Database:**
- Sqlite3
- [Sqlalchemy](https://docs.sqlalchemy.org/en/14/)
- **Payment:**
- [Yookassa](https://yookassa.ru/developers)
- **Debug:**
- Pylint
- Loguru
--------

## Installation 💾

[QUICK START](markdown/quick_start.md?)

--------

## Code Guide👋

[GUIDE](markdown/examples.md?)

--------
Binary file added assets/preview.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions markdown/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Code Guide

### To understand the architecture of the application, watch this [VIDEO](https://www.youtube.com/watch?v=W-0YoEYBSwU&t=23s)

## [Main Bot](../telegram_bot/main.py)
1. [Setup config.py](../telegram_bot/utils/config.py):
- PRICE - price for vip access
- HELPER_URL - telegram username (@username) for help btn
- BOT_URL - this bot username (@bot) for advert in free commands
- VIP_HELP_URL - site url for view vip help commands
- VIP_HELP_URL - site url for view free help commands

2. Add user commands [HERE](../telegram_bot/handlers/user/main.py)
3. Add admin commands [HERE](../telegram_bot/handlers/admin/main.py)

4. If you want to change the payment system, edit this [FILE](../telegram_bot/handlers/user/buy_vip.py)
--------

## [User Bot](../user_bot/main.py)
1. [Setup config.py](../user_bot/utils/config.py):
- PREFIX - sign for commands (.hello)

2. Add Free commands [HERE](../user_bot/handlers/common/main.py)
3. Add Vip commands [HERE](../user_bot/handlers/vip/main.py)

--------

### [BACK](../README.md)
23 changes: 23 additions & 0 deletions markdown/quick_start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# QUICK_START

1. Clone project
2. Create a virtual venv
3. Install requirements:
```
pip install --upgrade pip
pip install -r requirements.txt
```
4. [Setup environment variables](https://stackoverflow.com/questions/42708389/how-to-set-environment-variables-in-pycharm):
- [TOKEN](https://telegram.me/BotFather)
- [ADMIN_ID](https://telegram.me/myidbot)
- [API_HASH](https://my.telegram.org/)
- [API_ID](https://my.telegram.org/)
- [SHOP_ID](https://yookassa.ru/)
- [SHOP_TOKEN](https://yookassa.ru/)


5. Run run.py
6. When you first start your bot, use the /admin command (if you set ADMIN_ID)
--------

### [BACK](../README.md)
15 changes: 7 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Telegram
Pyrogram~=2.0.41
aiogram~=2.22.1

Pyrogram
aiogram

# Database
SQLAlchemy~=1.4.40
SQLAlchemy

# Debug
pylint_runner
loguru~=0.6.0
loguru

# Other
asyncio~=3.4.3
asyncio
tgcrypto


yookassa~=2.3.2
#Payment
yookassa
3 changes: 1 addition & 2 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

def main():
log_path = PathManager.get('logs/debug.log')
logger.add(log_path, format="{time} {level} {message}",
level="DEBUG", rotation="10:00", compression="zip")
logger.add(log_path, format="{time} {level} {message}", level="DEBUG", rotation="10:00", compression="zip")
start_telegram_bot()


Expand Down
1 change: 0 additions & 1 deletion run_user_bot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/python
from user_bot import start_user_bot

if __name__ == '__main__':
Expand Down
5 changes: 2 additions & 3 deletions telegram_bot/handlers/admin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ async def __admin_insert_tg_id(msg: Message, state: FSMContext):
bot: Bot = msg.bot
user_id = msg.from_user.id
admin_id = int(msg.text)
# todo remove Exception
try:
set_admin(admin_id)
set_vip(admin_id)
Expand All @@ -46,6 +45,7 @@ async def __admin_insert_tg_id(msg: Message, state: FSMContext):
await bot.send_message(user_id, 'Админ панель', reply_markup=get_admin_keyboard(user_id))
await state.set_state(AdminStates.ADMIN)


# endregion

# region Advert
Expand All @@ -72,11 +72,11 @@ async def __do_advertising(query: Message, state: FSMContext):
await bot.send_message(user_id, f"Рассылка выполнена - у {count} пользователей ✅")
await bot.send_message(user_id, 'Админ панель', reply_markup=get_admin_keyboard(user_id))


# endregion


async def __analytic(query: CallbackQuery, state: FSMContext) -> None:

users_count = get_user_count()
user_session_count = get_sessions_count()
vip_session_enable_count = get_sessions_enable_count(True)
Expand All @@ -95,7 +95,6 @@ async def __analytic(query: CallbackQuery, state: FSMContext) -> None:


def register_admin_handlers(dp: Dispatcher) -> None:

# region Msg handlers

dp.register_message_handler(__admin_insert_tg_id, IsAdmin(), content_types=['text'],
Expand Down
2 changes: 1 addition & 1 deletion telegram_bot/handlers/user/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from aiogram import Dispatcher, Bot
from aiogram.types import Message, CallbackQuery
from aiogram.types import Message

from telegram_bot.handlers.user.buy_vip import _register_vip_handlers
from telegram_bot.handlers.user.user_bot import _register_user_bot_handlers
Expand Down
2 changes: 1 addition & 1 deletion telegram_bot/handlers/user/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _buy_vip_text() -> str:
b("😯 Чем VIP отличается от бесплатного бота?\n"),
i("・ Отсутствие рекламного текста после анимаций"),
i("・ Доступ к VIP командам\n"),
b(f"Для покупки нажмите на кнопку Оплатить."),
b("Для покупки нажмите на кнопку Оплатить."),
b("После оплаты не забудьте ее проверить!")
)
return "\n".join(data)
1 change: 0 additions & 1 deletion telegram_bot/keyboards/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def get_main_keyboard(user_id: int) -> ReplyKeyboardMarkup:


def get_admin_keyboard(user_id: int) -> InlineKeyboardMarkup:
# todo: fix Exception
user = get_user_by_telegram_id(user_id)
if not user.admin:
raise Exception()
Expand Down

0 comments on commit 80d4ca5

Please sign in to comment.