Skip to content
This repository was archived by the owner on Oct 16, 2023. It is now read-only.

Commit 3c94ec4

Browse files
author
rozari0
committed
Made usable with latest pyrogram.
1 parent 0003805 commit 3c94ec4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1111
-1068
lines changed

Dockerfile

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
FROM williambutcherbot/python:latest
1+
FROM rozari0/python:latest
22

3-
WORKDIR /wbb
4-
RUN chmod 777 /wbb
3+
# Install dependencies
4+
RUN pacman -S --noconfirm git wget libxml2 libxslt zip
55

6-
# Installing Requirements
7-
RUN pip3 install -U pip
6+
# Downloading mongodb tools
7+
RUN wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2004-x86_64-100.5.2.tgz && tar -xf mongodb*.tgz && \
8+
mv mongodb-database-tools-ubuntu2004-x86_64-100.5.2/bin/* /bin/ && \
9+
rm -rf mongodb-database-tools-ubuntu2004-x86_64-100.5.2*
10+
11+
# Changing working directory and it's permission
12+
WORKDIR /app
13+
RUN chmod 777 /app
14+
15+
# Install python dependencies
816
COPY requirements.txt .
917
RUN pip3 install --no-cache-dir -U -r requirements.txt
1018

11-
# Copying All Source
19+
# Copy files to the working directory
1220
COPY . .
1321

14-
# If u don't want to use /update feature, comment the following and edit
15-
RUN python3 gitconfig.py
16-
17-
# Starting Bot
18-
CMD ["python3", "-m", "wbb"]
22+
# Run the application
23+
CMD ["python3","-m","nezuko"]

Procfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
worker: python3 -m wbb
1+
worker: python3 -m nezuko

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ cp sample_config.env config.env
6565
</h2>
6666

6767
```console
68-
python3 -m wbb
68+
python3 -m nezuko
6969
```
7070
<h1>
7171
<p align="center">
@@ -98,8 +98,8 @@ cp sample_config.env config.env
9898
</h3>
9999

100100
```console
101-
sudo docker build . -t wbb
102-
sudo docker run wbb
101+
sudo docker build . -t nezuko
102+
sudo docker run nezuko
103103
```
104104

105105
<h2 align="center">
@@ -109,7 +109,7 @@ sudo docker run wbb
109109
```py
110110
# Add license text here, get it from below
111111

112-
from wbb import app # This is bot's client
112+
from nezuko import app # This is bot's client
113113
from pyrogram import filters # pyrogram filters
114114
...
115115

@@ -123,11 +123,11 @@ __HELP__ = "Module help message"
123123
async def some_function(_, message):
124124
await message.reply_text("I'm already up!!")
125125

126-
# Many useful functions are in, wbb/utils/, wbb, and wbb/core/
126+
# Many useful functions are in, nezuko/utils/, nezuko, and nezuko/core/
127127
```
128128

129129
<h3 align="center">
130-
And put that file in wbb/modules/, restart and test your bot.
130+
And put that file in nezuko/modules/, restart and test your bot.
131131
</h3>
132132

133133
# Credits
@@ -137,4 +137,4 @@ Thanks to:
137137
- [`delivrance`](https://github.com/delivrance) for pyrogram.
138138
- [`rozari0`](https://github.com/rozari0) for some extra features & fixes.
139139

140-
And many more people who aren't mentioned here, but can be found in [Contributors](https://github.com/rozario/NezukoBot/graphs/contributors).
140+
And many more people who aren't mentioned here, but can be found in [Contributors](https://github.com/rozari0/NezukoBot/graphs/contributors).

gitconfig.py

-23
This file was deleted.

wbb/__init__.py renamed to nezuko/__init__.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
from Python_ARQ import ARQ
3636
from telegraph import Telegraph
3737

38-
3938
from sample_config import *
4039

4140
GBAN_LOG_GROUP_ID = GBAN_LOG_GROUP_ID
@@ -50,7 +49,7 @@
5049
# MongoDB client
5150
print("[INFO]: INITIALIZING DATABASE")
5251
mongo_client = MongoClient(MONGO_URL)
53-
db = mongo_client.wbb
52+
db = mongo_client.nezuko
5453

5554

5655
async def load_sudoers():
@@ -78,7 +77,7 @@ async def load_sudoers():
7877

7978
arq = ARQ(ARQ_API_URL, ARQ_API_KEY, aiohttpsession)
8079

81-
app = Client("wbb", bot_token=BOT_TOKEN, api_id=API_ID, api_hash=API_HASH)
80+
app = Client("nezuko", bot_token=BOT_TOKEN, api_id=API_ID, api_hash=API_HASH)
8281

8382
print("[INFO]: STARTING BOT CLIENT")
8483
app.start()

wbb/__main__.py renamed to nezuko/__main__.py

+23-41
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@
2929
from pyrogram import filters, idle
3030
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
3131

32-
from wbb import (BOT_NAME, BOT_USERNAME, LOG_GROUP_ID,
33-
aiohttpsession, app)
34-
from wbb.modules import ALL_MODULES
35-
from wbb.modules.sudoers import bot_sys_stats
36-
from wbb.utils import paginate_modules
37-
from wbb.utils.constants import MARKDOWN
38-
from wbb.utils.dbfunctions import clean_restart_stage
32+
from nezuko import BOT_NAME, BOT_USERNAME, LOG_GROUP_ID, aiohttpsession, app
33+
from nezuko.modules import ALL_MODULES
34+
from nezuko.modules.sudoers import bot_sys_stats
35+
from nezuko.utils import paginate_modules
36+
from nezuko.utils.constants import MARKDOWN
37+
from nezuko.utils.dbfunctions import clean_restart_stage
3938

4039
loop = asyncio.get_event_loop()
4140

@@ -46,16 +45,10 @@ async def start_bot():
4645
global HELPABLE
4746

4847
for module in ALL_MODULES:
49-
imported_module = importlib.import_module(f"wbb.modules.{module}")
50-
if (
51-
hasattr(imported_module, "__MODULE__")
52-
and imported_module.__MODULE__
53-
):
48+
imported_module = importlib.import_module(f"nezuko.modules.{module}")
49+
if hasattr(imported_module, "__MODULE__") and imported_module.__MODULE__:
5450
imported_module.__MODULE__ = imported_module.__MODULE__
55-
if (
56-
hasattr(imported_module, "__HELP__")
57-
and imported_module.__HELP__
58-
):
51+
if hasattr(imported_module, "__HELP__") and imported_module.__HELP__:
5952
HELPABLE[imported_module.__MODULE__.lower()] = imported_module
6053
bot_modules = ""
6154
j = 1
@@ -67,7 +60,7 @@ async def start_bot():
6760
bot_modules += "|{:<15}".format(i)
6861
j += 1
6962
print("+===============================================================+")
70-
print("| WBB |")
63+
print("| Nezuko |")
7164
print("+===============+===============+===============+===============+")
7265
print(bot_modules)
7366
print("+===============+===============+===============+===============+")
@@ -103,9 +96,7 @@ async def start_bot():
10396
home_keyboard_pm = InlineKeyboardMarkup(
10497
[
10598
[
106-
InlineKeyboardButton(
107-
text="Commands ❓", callback_data="bot_commands"
108-
),
99+
InlineKeyboardButton(text="Commands ❓", callback_data="bot_commands"),
109100
InlineKeyboardButton(
110101
text="Repo ❤️",
111102
url="https://github.com/rozari0/NezukoBot",
@@ -158,8 +149,10 @@ async def start_bot():
158149
@app.on_message(filters.command("start"))
159150
async def start(_, message):
160151
if message.chat.type != "private":
161-
return await message.reply_photo(photo="https://cdn.awwni.me/2gj9h.jpg",
162-
caption="Pm Me For More Details.", reply_markup=keyboard
152+
return await message.reply_photo(
153+
photo="https://cdn.awwni.me/2gj9h.jpg",
154+
caption="Pm Me For More Details.",
155+
reply_markup=keyboard,
163156
)
164157
if len(message.text.split()) > 1:
165158
name = (message.text.split(None, 1)[1]).lower()
@@ -181,7 +174,8 @@ async def start(_, message):
181174
reply_markup=keyb,
182175
)
183176
else:
184-
await message.reply_photo(photo="https://cdn.awwni.me/2gj9h.jpg",
177+
await message.reply_photo(
178+
photo="https://cdn.awwni.me/2gj9h.jpg",
185179
caption=home_text_pm,
186180
reply_markup=home_keyboard_pm,
187181
)
@@ -209,13 +203,9 @@ async def help_command(_, message):
209203
reply_markup=key,
210204
)
211205
else:
212-
await message.reply(
213-
"PM Me For More Details.", reply_markup=keyboard
214-
)
206+
await message.reply("PM Me For More Details.", reply_markup=keyboard)
215207
else:
216-
await message.reply(
217-
"Pm Me For More Details.", reply_markup=keyboard
218-
)
208+
await message.reply("Pm Me For More Details.", reply_markup=keyboard)
219209
elif len(message.command) >= 2:
220210
name = (message.text.split(None, 1)[1]).lower()
221211
if str(name) in HELPABLE:
@@ -225,18 +215,14 @@ async def help_command(_, message):
225215
)
226216
await message.reply(text, disable_web_page_preview=True)
227217
else:
228-
text, help_keyboard = await help_parser(
229-
message.from_user.first_name
230-
)
218+
text, help_keyboard = await help_parser(message.from_user.first_name)
231219
await message.reply(
232220
text,
233221
reply_markup=help_keyboard,
234222
disable_web_page_preview=True,
235223
)
236224
else:
237-
text, help_keyboard = await help_parser(
238-
message.from_user.first_name
239-
)
225+
text, help_keyboard = await help_parser(message.from_user.first_name)
240226
await message.reply(
241227
text, reply_markup=help_keyboard, disable_web_page_preview=True
242228
)
@@ -298,9 +284,7 @@ async def help_button(client, query):
298284
if mod_match:
299285
module = mod_match.group(1)
300286
text = (
301-
"{} **{}**:\n".format(
302-
"Here is the help for", HELPABLE[module].__MODULE__
303-
)
287+
"{} **{}**:\n".format("Here is the help for", HELPABLE[module].__MODULE__)
304288
+ HELPABLE[module].__HELP__
305289
)
306290

@@ -341,9 +325,7 @@ async def help_button(client, query):
341325
elif back_match:
342326
await query.message.edit(
343327
text=top_text,
344-
reply_markup=InlineKeyboardMarkup(
345-
paginate_modules(0, HELPABLE, "help")
346-
),
328+
reply_markup=InlineKeyboardMarkup(paginate_modules(0, HELPABLE, "help")),
347329
disable_web_page_preview=True,
348330
)
349331

wbb/core/decorators/errors.py renamed to nezuko/core/decorators/errors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from pyrogram.errors.exceptions.forbidden_403 import ChatWriteForbidden
88

9-
from wbb import LOG_GROUP_ID, app
9+
from nezuko import LOG_GROUP_ID, app
1010

1111

1212
def split_limits(text):
File renamed without changes.

wbb/core/decorators/permissions.py renamed to nezuko/core/decorators/permissions.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
from pyrogram.errors.exceptions.forbidden_403 import ChatWriteForbidden
2828
from pyrogram.types import Message
2929

30-
from wbb import SUDOERS, app
31-
from wbb.modules.admin import member_permissions
30+
from nezuko import SUDOERS, app
31+
from nezuko.modules.admin import member_permissions
3232

3333

3434
async def authorised(func, subFunc2, client, message, *args, **kwargs):
@@ -67,10 +67,7 @@ async def subFunc2(client, message: Message, *args, **kwargs):
6767
chatID = message.chat.id
6868
if not message.from_user:
6969
# For anonymous admins
70-
if (
71-
message.sender_chat
72-
and message.sender_chat.id == message.chat.id
73-
):
70+
if message.sender_chat and message.sender_chat.id == message.chat.id:
7471
return await authorised(
7572
func,
7673
subFunc2,
@@ -85,9 +82,7 @@ async def subFunc2(client, message: Message, *args, **kwargs):
8582
permissions = await member_permissions(chatID, userID)
8683
if userID not in SUDOERS and permission not in permissions:
8784
return await unauthorised(message, permission, subFunc2)
88-
return await authorised(
89-
func, subFunc2, client, message, *args, **kwargs
90-
)
85+
return await authorised(func, subFunc2, client, message, *args, **kwargs)
9186

9287
return subFunc2
9388

wbb/core/filters.py renamed to nezuko/core/filters.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
from pyrogram import filters as filters_
2525
from pyrogram.types import Message
2626

27-
from wbb import SUDOERS
28-
from wbb import USERBOT_ID as OWNER_ID
29-
from wbb.utils.functions import get_urls_from_text
27+
from nezuko import SUDOERS
28+
from nezuko import USERBOT_ID as OWNER_ID
29+
from nezuko.utils.functions import get_urls_from_text
3030

3131

3232
def url(_, __, message: Message) -> bool:

wbb/core/keyboard.py renamed to nezuko/core/keyboard.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from pykeyboard import InlineKeyboard
2525
from pyrogram.types import InlineKeyboardButton as Ikb
2626

27-
from wbb.utils.functions import get_urls_from_text as is_url
27+
from nezuko.utils.functions import get_urls_from_text as is_url
2828

2929

3030
def keyboard(buttons_list, row_width: int = 2):
File renamed without changes.

wbb/core/tasks.py renamed to nezuko/core/tasks.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from pyrogram import filters
55
from pyrogram.types import Message
66

7-
from wbb import BOT_ID, SUDOERS
8-
from wbb.core.sections import bold, section, w
7+
from nezuko import BOT_ID, SUDOERS
8+
from nezuko.core.sections import bold, section, w
99

1010
tasks = {}
1111
TASKS_LOCK = Lock()

wbb/core/types/InlineQueryResult.py renamed to nezuko/core/types/InlineQueryResult.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ async def write(self, client: "pyrogram.Client"):
157157
thumb=thumb,
158158
content=audio,
159159
send_message=(
160-
await self.input_message_content.write(
161-
client, self.reply_markup
162-
)
160+
await self.input_message_content.write(client, self.reply_markup)
163161
if self.input_message_content
164162
else raw.types.InputBotInlineMessageMediaAuto(
165163
reply_markup=await self.reply_markup.write(client)
@@ -258,9 +256,7 @@ async def write(self, client: "pyrogram.Client"):
258256
description=self.description,
259257
document=document,
260258
send_message=(
261-
await self.input_message_content.write(
262-
client, self.reply_markup
263-
)
259+
await self.input_message_content.write(client, self.reply_markup)
264260
if self.input_message_content
265261
else raw.types.InputBotInlineMessageMediaAuto(
266262
reply_markup=await self.reply_markup.write(client)
@@ -292,9 +288,7 @@ def get_input_file_from_file_id(
292288
)
293289

294290
if file_type in (FileType.THUMBNAIL, FileType.CHAT_PHOTO):
295-
raise ValueError(
296-
f"This file_id can only be used for download: {file_id}"
297-
)
291+
raise ValueError(f"This file_id can only be used for download: {file_id}")
298292

299293
if file_type in PHOTO_TYPES:
300294
return raw.types.InputPhoto(

nezuko/core/types/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# flake8: noqa
2+
3+
from .InlineQueryResult import InlineQueryResultAudio, InlineQueryResultCachedDocument

0 commit comments

Comments
 (0)