Skip to content

Commit 2d87f1e

Browse files
committed
added admin commands
1 parent d229362 commit 2d87f1e

File tree

6 files changed

+113
-130
lines changed

6 files changed

+113
-130
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ python3 main.py
8383
### Variables
8484

8585
* `API_HASH` Your API Hash from my.telegram.org
86-
* `API_ID` Your API ID from my.telegram.org
86+
* `APP_ID` Your API ID from my.telegram.org
8787
* `TG_BOT_TOKEN` Your bot token from @BotFather
8888
* `OWNER_ID` Must enter Your Telegram Id
8989
* `CHANNEL_ID` Your Channel ID eg:- -100xxxxxxxx

app.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"sharing"
88
],
99
"repository": "https://github.com/CodeXBotz/File-Sharing-Bot",
10-
"logo": "https://telegra.ph/file/14d3013fda21281c54b61.jpg",
10+
"logo": "https://ibb.co/FgPVtzw",
1111
"env": {
1212
"TG_BOT_TOKEN": {
1313
"description": "Your Bot token, Get it from @Botfather",
@@ -21,6 +21,14 @@
2121
"description": "your app id, take it from my.telegram.org",
2222
"value": ""
2323
},
24+
"DATABASE_URL": {
25+
"description": "Paste your mongo db url",
26+
"value": "url"
27+
},
28+
"DATABASE_NAME":{
29+
"description": "Enter your DATABASE_NAME ",
30+
"value": "filesharexbot"
31+
},
2432
"API_HASH":{
2533
"description": "your api hash, take it from my.telegram.org",
2634
"value": ""
@@ -52,14 +60,6 @@
5260
"required": false
5361
}
5462
},
55-
"addons": [
56-
{
57-
"plan": "heroku-postgresql",
58-
"options": {
59-
"version": "12"
60-
}
61-
}
62-
],
6363
"buildpacks": [
6464
{
6565
"url": "heroku/python"

bot.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
88

99
from config import API_HASH, APP_ID, LOGGER, TG_BOT_TOKEN, TG_BOT_WORKERS, FORCE_SUB_CHANNEL, CHANNEL_ID
1010

11+
12+
name ="""
13+
░█████╗░░█████╗░██████╗░███████╗██╗░░██╗██████╗░░█████╗░████████╗███████╗
14+
██╔══██╗██╔══██╗██╔══██╗██╔════╝╚██╗██╔╝██╔══██╗██╔══██╗╚══██╔══╝╚════██║
15+
██║░░╚═╝██║░░██║██║░░██║█████╗░░░╚███╔╝░██████╦╝██║░░██║░░░██║░░░░░███╔═╝
16+
██║░░██╗██║░░██║██║░░██║██╔══╝░░░██╔██╗░██╔══██╗██║░░██║░░░██║░░░██╔══╝░░
17+
╚█████╔╝╚█████╔╝██████╔╝███████╗██╔╝╚██╗██████╦╝╚█████╔╝░░░██║░░░███████╗
18+
░╚════╝░░╚════╝░╚═════╝░╚══════╝╚═╝░░╚═╝╚═════╝░░╚════╝░░░░╚═╝░░░╚══════╝
19+
"""
20+
21+
1122
class Bot(Client):
1223
def __init__(self):
1324
super().__init__(
@@ -53,6 +64,12 @@ async def start(self):
5364

5465
self.set_parse_mode(ParseMode.HTML)
5566
self.LOGGER(__name__).info(f"Bot Running..!\n\nCreated by \nhttps://t.me/CodeXBotz")
67+
self.LOGGER(__name__).info(f"""░█████╗░░█████╗░██████╗░███████╗██╗░░██╗██████╗░░█████╗░████████╗███████╗
68+
██╔══██╗██╔══██╗██╔══██╗██╔════╝╚██╗██╔╝██╔══██╗██╔══██╗╚══██╔══╝╚════██║
69+
██║░░╚═╝██║░░██║██║░░██║█████╗░░░╚███╔╝░██████╦╝██║░░██║░░░██║░░░░░███╔═╝
70+
██║░░██╗██║░░██║██║░░██║██╔══╝░░░██╔██╗░██╔══██╗██║░░██║░░░██║░░░██╔══╝░░
71+
╚█████╔╝╚█████╔╝██████╔╝███████╗██╔╝╚██╗██████╦╝╚█████╔╝░░░██║░░░███████╗
72+
░╚════╝░░╚════╝░╚═════╝░╚══════╝╚═╝░░╚═╝╚═════╝░░╚════╝░░░░╚═╝░░░╚══════╝""")
5673
self.username = usr_bot_me.username
5774

5875
async def stop(self, *args):

database/sql.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

plugins/admin,py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#(©)CodeXBotz
2+
3+
4+
5+
6+
import asyncio
7+
from bot import Bot
8+
from config import ADMINS
9+
from pyrogram import filters, Client
10+
from pyrogram.types import Message
11+
from database.database import del_user, full_userbase
12+
from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated
13+
14+
15+
#=====================================================================================##
16+
17+
WAIT_MSG = """"<b>Processing ...</b>"""
18+
19+
REPLY_ERROR = """<code>Use this command as a replay to any telegram message with out any spaces.</code>"""
20+
21+
#=====================================================================================##
22+
23+
24+
25+
@Bot.on_message(filters.command('users') & filters.private & filters.user(ADMINS))
26+
async def get_users(client: Bot, message: Message):
27+
msg = await client.send_message(chat_id=message.chat.id, text=WAIT_MSG)
28+
users = await full_userbase()
29+
await msg.edit(f"{len(users)} users are using this bot")
30+
31+
32+
@Bot.on_message(filters.private & filters.command('broadcast') & filters.user(ADMINS))
33+
async def send_text(client: Bot, message: Message):
34+
if message.reply_to_message:
35+
query = await full_userbase()
36+
broadcast_msg = message.reply_to_message
37+
total = 0
38+
successful = 0
39+
blocked = 0
40+
deleted = 0
41+
unsuccessful = 0
42+
43+
pls_wait = await message.reply("<i>Broadcasting Message.. This will Take Some Time</i>")
44+
for chat_id in query:
45+
try:
46+
await broadcast_msg.copy(chat_id)
47+
successful += 1
48+
except FloodWait as e:
49+
await asyncio.sleep(e.x)
50+
await broadcast_msg.copy(chat_id)
51+
successful += 1
52+
except UserIsBlocked:
53+
await del_user(chat_id)
54+
blocked += 1
55+
except InputUserDeactivated:
56+
await del_user(chat_id)
57+
deleted += 1
58+
except:
59+
unsuccessful += 1
60+
pass
61+
total += 1
62+
63+
status = f"""<b><u>Broadcast Completed</u>
64+
65+
Total Users: <code>{total}</code>
66+
Successful: <code>{successful}</code>
67+
Blocked Users: <code>{blocked}</code>
68+
Deleted Accounts: <code>{deleted}</code>
69+
Unsuccessful: <code>{unsuccessful}</code></b>"""
70+
71+
return await pls_wait.edit(status)
72+
73+
else:
74+
msg = await message.reply(REPLY_ERROR)
75+
await asyncio.sleep(8)
76+
await msg.delete()

plugins/start.py

Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
#(©)CodeXBotz
2+
3+
4+
5+
26
import os
37
import asyncio
4-
from pyrogram import Client, filters, __version__
5-
from pyrogram.enums import ParseMode
6-
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
7-
from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated
8-
98
from bot import Bot
10-
from config import ADMINS, FORCE_MSG, START_MSG, OWNER_ID, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT
9+
from pyrogram.enums import ParseMode
10+
from pyrogram import Client, filters, __version__
11+
from database.database import add_user, present_user
1112
from helper_func import subscribed, encode, decode, get_messages
12-
from database.database import add_user, del_user, full_userbase, present_user
13-
13+
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
14+
from config import FORCE_MSG, START_MSG, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT
1415

15-
#=====================================================================================##
1616

17-
WAIT_MSG = """"<b>Processing ...</b>"""
1817

19-
REPLY_ERROR = """<code>Use this command as a replay to any telegram message with out any spaces.</code>"""
2018

21-
#=====================================================================================##
2219

2320

2421
@Bot.on_message(filters.command('start') & filters.private & subscribed)
@@ -142,56 +139,4 @@ async def not_joined(client: Client, message: Message):
142139
reply_markup = InlineKeyboardMarkup(buttons),
143140
quote = True,
144141
disable_web_page_preview = True
145-
)
146-
147-
@Bot.on_message(filters.command('users') & filters.private & filters.user(ADMINS))
148-
async def get_users(client: Bot, message: Message):
149-
msg = await client.send_message(chat_id=message.chat.id, text=WAIT_MSG)
150-
users = await full_userbase()
151-
await msg.edit(f"{len(users)} users are using this bot")
152-
153-
@Bot.on_message(filters.private & filters.command('broadcast') & filters.user(ADMINS))
154-
async def send_text(client: Bot, message: Message):
155-
if message.reply_to_message:
156-
query = await full_userbase()
157-
broadcast_msg = message.reply_to_message
158-
total = 0
159-
successful = 0
160-
blocked = 0
161-
deleted = 0
162-
unsuccessful = 0
163-
164-
pls_wait = await message.reply("<i>Broadcasting Message.. This will Take Some Time</i>")
165-
for chat_id in query:
166-
try:
167-
await broadcast_msg.copy(chat_id)
168-
successful += 1
169-
except FloodWait as e:
170-
await asyncio.sleep(e.x)
171-
await broadcast_msg.copy(chat_id)
172-
successful += 1
173-
except UserIsBlocked:
174-
await del_user(chat_id)
175-
blocked += 1
176-
except InputUserDeactivated:
177-
await del_user(chat_id)
178-
deleted += 1
179-
except:
180-
unsuccessful += 1
181-
pass
182-
total += 1
183-
184-
status = f"""<b><u>Broadcast Completed</u>
185-
186-
Total Users: <code>{total}</code>
187-
Successful: <code>{successful}</code>
188-
Blocked Users: <code>{blocked}</code>
189-
Deleted Accounts: <code>{deleted}</code>
190-
Unsuccessful: <code>{unsuccessful}</code></b>"""
191-
192-
return await pls_wait.edit(status)
193-
194-
else:
195-
msg = await message.reply(REPLY_ERROR)
196-
await asyncio.sleep(8)
197-
await msg.delete()
142+
)

0 commit comments

Comments
 (0)