Skip to content

Commit 88b7cd5

Browse files
committed
init stucture + ping plugin
1 parent 5284e64 commit 88b7cd5

15 files changed

+165
-0
lines changed

.deepsource.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version = 1
2+
3+
[[analyzers]]
4+
name = "python"
5+
enabled = true
6+
dependency_file_paths = ["requirements.txt"]
7+
8+
[analyzers.meta]
9+
runtime_version = "3.x.x"
10+
max_line_length = 100

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,11 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
# config files
132+
config.ini
133+
config.env
134+
.vscode/
135+
*.session
136+
log.txt
137+
unknown_errors.txt

.pep8speaks.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# File : .pep8speaks.yml
2+
3+
scanner:
4+
linter: flake8
5+
6+
flake8:
7+
max-line-length: 100
8+
9+
message:
10+
opened:
11+
header: "@{name}, Thanks for opening this PR."
12+
updated:
13+
header: "@{name}, Thanks for updating this PR."

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
worker: bash run

assistant/__init__.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
2+
#
3+
# This file is part of < https://github.com/UsergeTeam/Userge-Assistant > project,
4+
# and is released under the "GNU v3.0 License Agreement".
5+
# Please see < https://github.com/Userge-Assistant/blob/master/LICENSE >
6+
#
7+
# All rights reserved.
8+
9+
from .logger import logging #noqa
10+
from .config import Config #noqa
11+
from .bot import bot #noqa

assistant/__main__.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
2+
#
3+
# This file is part of < https://github.com/UsergeTeam/Userge-Assistant > project,
4+
# and is released under the "GNU v3.0 License Agreement".
5+
# Please see < https://github.com/Userge-Assistant/blob/master/LICENSE >
6+
#
7+
# All rights reserved.
8+
9+
from assistant import bot
10+
11+
if __name__ == "__main__":
12+
bot.run()

assistant/bot.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
2+
#
3+
# This file is part of < https://github.com/UsergeTeam/Userge-Assistant > project,
4+
# and is released under the "GNU v3.0 License Agreement".
5+
# Please see < https://github.com/Userge-Assistant/blob/master/LICENSE >
6+
#
7+
# All rights reserved.
8+
9+
from pyrogram import Client
10+
11+
from assistant import Config, logging
12+
13+
LOG = logging.getLogger(__name__)
14+
15+
bot = Client(
16+
"userge-assistant",
17+
api_id=Config.APP_ID,
18+
api_hash=Config.API_HASH,
19+
bot_token=Config.BOT_TOKEN,
20+
plugins={'root': "assistant/plugins"}
21+
)
22+
23+
LOG.info("assistant-bot initialized!")

assistant/config.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
2+
#
3+
# This file is part of < https://github.com/UsergeTeam/Userge-Assistant > project,
4+
# and is released under the "GNU v3.0 License Agreement".
5+
# Please see < https://github.com/Userge-Assistant/blob/master/LICENSE >
6+
#
7+
# All rights reserved.
8+
9+
import os
10+
11+
from pyrogram import Filters
12+
from dotenv import load_dotenv
13+
14+
if os.path.isfile("config.env"):
15+
load_dotenv("config.env")
16+
17+
18+
class Config:
19+
APP_ID = int(os.environ.get("APP_ID", 0))
20+
API_HASH = os.environ.get("API_HASH")
21+
BOT_TOKEN = os.environ.get("BOT_TOKEN")
22+
AUTH_CHATS = Filters.chat(list(set(map(int, os.environ.get("AUTH_CHATS", "123").split()))))

assistant/logger.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
2+
#
3+
# This file is part of < https://github.com/UsergeTeam/Userge-Assistant > project,
4+
# and is released under the "GNU v3.0 License Agreement".
5+
# Please see < https://github.com/Userge-Assistant/blob/master/LICENSE >
6+
#
7+
# All rights reserved.
8+
9+
import logging
10+
11+
logging.basicConfig(
12+
level=logging.INFO,
13+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
14+
)
15+
16+
logging.getLogger("pyrogram").setLevel(logging.WARNING)

assistant/plugins/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
2+
#
3+
# This file is part of < https://github.com/UsergeTeam/Userge-Assistant > project,
4+
# and is released under the "GNU v3.0 License Agreement".
5+
# Please see < https://github.com/Userge-Assistant/blob/master/LICENSE >
6+
#
7+
# All rights reserved.

assistant/plugins/ping.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
2+
#
3+
# This file is part of < https://github.com/UsergeTeam/Userge-Assistant > project,
4+
# and is released under the "GNU v3.0 License Agreement".
5+
# Please see < https://github.com/Userge-Assistant/blob/master/LICENSE >
6+
#
7+
# All rights reserved.
8+
9+
from datetime import datetime
10+
11+
from pyrogram import Message, Filters
12+
13+
from assistant import bot, Config
14+
15+
16+
@bot.on_message(Config.AUTH_CHATS & Filters.command("ping"))
17+
async def _ping(_, message: Message):
18+
start = datetime.now()
19+
replied = await message.reply('`Pong!`')
20+
end = datetime.now()
21+
m_s = (end - start).microseconds / 1000
22+
await replied.edit(f"**Pong!**\n`{m_s} ms`")

assistant/utils/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
2+
#
3+
# This file is part of < https://github.com/UsergeTeam/Userge-Assistant > project,
4+
# and is released under the "GNU v3.0 License Agreement".
5+
# Please see < https://github.com/Userge-Assistant/blob/master/LICENSE >
6+
#
7+
# All rights reserved.

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
git+https://github.com/pyrogram/pyrogram.git@asyncio-dev
22
aiofiles
33
aiohttp
4+
python-dotenv

run

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
4+
#
5+
# This file is part of < https://github.com/UsergeTeam/Userge-Assistant > project,
6+
# and is released under the "GNU v3.0 License Agreement".
7+
# Please see < https://github.com/Userge-Assistant/blob/master/LICENSE >
8+
#
9+
# All rights reserved.
10+
11+
python3.8 -m assistant

runtime.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-3.8.5

0 commit comments

Comments
 (0)