Обновление структуры
догрузил в гит остальные файлы (git add .), а то до этого забыл. Почистил requirements.txt, чтобы это выглядело по-человечески. Остальные библиотеки подтягиваются прописанными библиотеками. Версии указывал строго
This commit is contained in:
parent
529b5aeb69
commit
d0f0142111
14
.env.dist
Normal file
14
.env.dist
Normal file
|
@ -0,0 +1,14 @@
|
|||
|
||||
# Telegram API Token
|
||||
BOT_TOKEN=
|
||||
|
||||
# Не надо использовать пробел после ","
|
||||
ADMINS_ID=123456789,987654321
|
||||
|
||||
# Указываем пропускать ли боту апдейты при запуске
|
||||
SKIP_UPDATES=False
|
||||
|
||||
# Параметры для Redis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PORT=6379
|
||||
|
37
data/permissions.py
Normal file
37
data/permissions.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
from aiogram import types
|
||||
|
||||
# Права пользователя, только вошедшего в чат
|
||||
new_user_added = types.ChatPermissions(
|
||||
can_send_messages=False,
|
||||
can_send_media_messages=False,
|
||||
can_send_polls=False,
|
||||
can_send_other_messages=False,
|
||||
can_add_web_page_previews=False,
|
||||
can_invite_users=False,
|
||||
can_change_info=False,
|
||||
can_pin_messages=False,
|
||||
)
|
||||
|
||||
# Права пользователя, подтвердившего, что он не бот
|
||||
user_allowed = types.ChatPermissions(
|
||||
can_send_messages=True,
|
||||
can_send_media_messages=True,
|
||||
can_send_polls=True,
|
||||
can_send_other_messages=True,
|
||||
can_add_web_page_previews=True,
|
||||
can_invite_users=True,
|
||||
can_change_info=False,
|
||||
can_pin_messages=False,
|
||||
)
|
||||
|
||||
# Права пользователя в муте
|
||||
user_ro = types.ChatPermissions(
|
||||
can_send_messages=False,
|
||||
can_send_media_messages=False,
|
||||
can_send_polls=False,
|
||||
can_send_other_messages=False,
|
||||
can_add_web_page_previews=False,
|
||||
can_invite_users=True,
|
||||
can_change_info=False,
|
||||
can_pin_messages=False,
|
||||
)
|
13
docker-compose.yml
Normal file
13
docker-compose.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
version: '3.1'
|
||||
services:
|
||||
commonmoder:
|
||||
container_name: commonmoder
|
||||
build:
|
||||
context: .
|
||||
network_mode: "host"
|
||||
|
||||
command: python app.py
|
||||
restart: always
|
||||
|
||||
env_file:
|
||||
- ".env"
|
15
filters/chat_filters.py
Normal file
15
filters/chat_filters.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from aiogram import types
|
||||
from aiogram.dispatcher.filters import BoundFilter
|
||||
|
||||
|
||||
class IsGroup(BoundFilter):
|
||||
|
||||
async def check(self, message: types.Message):
|
||||
return message.chat.type in (types.ChatType.GROUP,
|
||||
types.ChatType.SUPER_GROUP)
|
||||
|
||||
|
||||
class IsPrivate(BoundFilter):
|
||||
|
||||
async def check(self, message: types.Message):
|
||||
return message.chat.type == types.ChatType.PRIVATE
|
11
filters/user_filters.py
Normal file
11
filters/user_filters.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from aiogram import types
|
||||
from aiogram.dispatcher.filters import BoundFilter
|
||||
|
||||
from loader import bot
|
||||
|
||||
|
||||
class IsContributor(BoundFilter):
|
||||
|
||||
async def check(self, message: types.Message):
|
||||
member = await bot.get_chat_member(message.chat.id, message.from_user.id)
|
||||
return member.custom_title == "Contributor"
|
3
handlers/essential/__init__.py
Normal file
3
handlers/essential/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from .errors import dp
|
||||
|
||||
__all__ = ["dp"]
|
56
handlers/essential/errors.py
Normal file
56
handlers/essential/errors.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
from loguru import logger
|
||||
|
||||
from loader import dp
|
||||
|
||||
|
||||
@dp.errors_handler()
|
||||
async def errors_handler(update, exception):
|
||||
"""
|
||||
Exceptions handler. Catches all exceptions within task factory tasks.
|
||||
:param dispatcher:
|
||||
:param update:
|
||||
:param exception:
|
||||
:return: stdout logging
|
||||
"""
|
||||
from aiogram.utils.exceptions import (Unauthorized, InvalidQueryID, TelegramAPIError,
|
||||
CantDemoteChatCreator, MessageNotModified, MessageToDeleteNotFound,
|
||||
MessageTextIsEmpty, RetryAfter,
|
||||
CantParseEntities, MessageCantBeDeleted)
|
||||
|
||||
if isinstance(exception, CantDemoteChatCreator):
|
||||
logger.debug("Can't demote chat creator")
|
||||
return True
|
||||
|
||||
if isinstance(exception, MessageNotModified):
|
||||
logger.debug('Message is not modified')
|
||||
return True
|
||||
if isinstance(exception, MessageCantBeDeleted):
|
||||
logger.debug('Message cant be deleted')
|
||||
return True
|
||||
|
||||
if isinstance(exception, MessageToDeleteNotFound):
|
||||
logger.debug('Message to delete not found')
|
||||
return True
|
||||
|
||||
if isinstance(exception, MessageTextIsEmpty):
|
||||
logger.debug('MessageTextIsEmpty')
|
||||
return True
|
||||
|
||||
if isinstance(exception, Unauthorized):
|
||||
logger.info(f'Unauthorized: {exception}')
|
||||
return True
|
||||
|
||||
if isinstance(exception, InvalidQueryID):
|
||||
logger.exception(f'InvalidQueryID: {exception} \nUpdate: {update}')
|
||||
return True
|
||||
|
||||
if isinstance(exception, TelegramAPIError):
|
||||
logger.exception(f'TelegramAPIError: {exception} \nUpdate: {update}')
|
||||
return True
|
||||
if isinstance(exception, RetryAfter):
|
||||
logger.exception(f'RetryAfter: {exception} \nUpdate: {update}')
|
||||
return True
|
||||
if isinstance(exception, CantParseEntities):
|
||||
logger.exception(f'CantParseEntities: {exception} \nUpdate: {update}')
|
||||
return True
|
||||
logger.exception(f'Update: {update} \n{exception}')
|
1
handlers/private/__init__.py
Normal file
1
handlers/private/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
# __all__ = ["dp"]
|
|
@ -1,44 +1,3 @@
|
|||
|
||||
# Autocreated by
|
||||
# pip freeze > requirements.txt
|
||||
|
||||
aiogram==2.8
|
||||
aiohttp==3.6.2
|
||||
aioredis==1.3.1
|
||||
appdirs==1.4.3
|
||||
APScheduler==3.6.3
|
||||
async-timeout==3.0.1
|
||||
asyncio==3.4.3
|
||||
attrs==19.3.0
|
||||
Babel==2.8.0
|
||||
CacheControl==0.12.6
|
||||
certifi==2020.4.5.1
|
||||
chardet==3.0.4
|
||||
colorama==0.4.3
|
||||
contextlib2==0.6.0
|
||||
distlib==0.3.0
|
||||
distro==1.4.0
|
||||
environs==7.4.0
|
||||
hiredis==1.0.1
|
||||
html5lib==1.0.1
|
||||
idna==2.9
|
||||
ipaddr==2.2.0
|
||||
lockfile==0.12.2
|
||||
loguru==0.4.1
|
||||
marshmallow==3.6.0
|
||||
msgpack==0.6.2
|
||||
multidict==4.7.5
|
||||
packaging==20.3
|
||||
pep517==0.8.2
|
||||
progress==1.5
|
||||
pyparsing==2.4.6
|
||||
pytoml==0.1.21
|
||||
pytz==2020.1
|
||||
redis==3.5.1
|
||||
requests==2.22.0
|
||||
retrying==1.3.3
|
||||
six==1.14.0
|
||||
tzlocal==2.1
|
||||
urllib3==1.25.8
|
||||
webencodings==0.5.1
|
||||
yarl==1.4.2
|
||||
environs==8.0.0
|
||||
loguru==0.5.0
|
||||
|
|
7
utils/set_bot_commands.py
Normal file
7
utils/set_bot_commands.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from aiogram import types
|
||||
|
||||
|
||||
async def set_default_commands(dp):
|
||||
await dp.bot.set_my_commands([
|
||||
types.BotCommand("start", "Начало работы с ботом"),
|
||||
])
|
Loading…
Reference in New Issue
Block a user