6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
Python3
\n○ Library : Pyrogram asyncio {__version__}\n○ Source Code : Click here\n○ Channel : @susanta_bhandarii\n○ Support Group : @susanta_support",
14 | disable_web_page_preview = True,
15 | reply_markup = InlineKeyboardMarkup(
16 | [
17 | [
18 | InlineKeyboardButton("🔒 Close", callback_data = "close")
19 | ]
20 | ]
21 | )
22 | )
23 | elif data == "close":
24 | await query.message.delete()
25 | try:
26 | await query.message.reply_to_message.delete()
27 | except:
28 | pas
29 |
--------------------------------------------------------------------------------
/plugins/channel_post.py:
--------------------------------------------------------------------------------
1 | #(©)Codexbotz
2 |
3 | import asyncio
4 | from pyrogram import filters, Client
5 | from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
6 | from pyrogram.errors import FloodWait
7 |
8 | from bot import Bot
9 | from config import ADMINS, CHANNEL_ID, DISABLE_CHANNEL_BUTTON
10 | from helper_func import encode
11 |
12 | @Bot.on_message(filters.private & filters.user(ADMINS) & ~filters.command(['start','users','broadcast','batch','genlink','stats']))
13 | async def channel_post(client: Client, message: Message):
14 | reply_text = await message.reply_text("Please Wait...!", quote = True)
15 | try:
16 | post_message = await message.copy(chat_id = client.db_channel.id, disable_notification=True)
17 | except FloodWait as e:
18 | await asyncio.sleep(e.x)
19 | post_message = await message.copy(chat_id = client.db_channel.id, disable_notification=True)
20 | except Exception as e:
21 | print(e)
22 | await reply_text.edit_text("Something went Wrong..!")
23 | return
24 | converted_id = post_message.id * abs(client.db_channel.id)
25 | string = f"get-{converted_id}"
26 | base64_string = await encode(string)
27 | link = f"https://t.me/{client.username}?start={base64_string}"
28 |
29 | reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("🔁 Share URL", url=f'https://telegram.me/share/url?url={link}')]])
30 |
31 | await reply_text.edit(f"Here is your link\n\n{link}", reply_markup=reply_markup, disable_web_page_preview = True)
32 |
33 | if not DISABLE_CHANNEL_BUTTON:
34 | await post_message.edit_reply_markup(reply_markup)
35 |
36 | @Bot.on_message(filters.channel & filters.incoming & filters.chat(CHANNEL_ID))
37 | async def new_post(client: Client, message: Message):
38 |
39 | if DISABLE_CHANNEL_BUTTON:
40 | return
41 |
42 | converted_id = message.id * abs(client.db_channel.id)
43 | string = f"get-{converted_id}"
44 | base64_string = await encode(string)
45 | link = f"https://t.me/{client.username}?start={base64_string}"
46 | reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("🔁 Share URL", url=f'https://telegram.me/share/url?url={link}')]])
47 | try:
48 | await message.edit_reply_markup(reply_markup)
49 | except Exception as e:
50 | print(e)
51 | pass
52 |
--------------------------------------------------------------------------------
/plugins/link_generator.py:
--------------------------------------------------------------------------------
1 | #(©)Codexbotz
2 |
3 | from pyrogram import Client, filters
4 | from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
5 | from bot import Bot
6 | from config import ADMINS
7 | from helper_func import encode, get_message_id
8 |
9 | @Bot.on_message(filters.private & filters.user(ADMINS) & filters.command('batch'))
10 | async def batch(client: Client, message: Message):
11 | while True:
12 | try:
13 | first_message = await client.ask(text = "Forward the First Message from DB Channel (with Quotes)..\n\nor Send the DB Channel Post Link", chat_id = message.from_user.id, filters=(filters.forwarded | (filters.text & ~filters.forwarded)), timeout=60)
14 | except:
15 | return
16 | f_msg_id = await get_message_id(client, first_message)
17 | if f_msg_id:
18 | break
19 | else:
20 | await first_message.reply("❌ Error\n\nthis Forwarded Post is not from my DB Channel or this Link is taken from DB Channel", quote = True)
21 | continue
22 |
23 | while True:
24 | try:
25 | second_message = await client.ask(text = "Forward the Last Message from DB Channel (with Quotes)..\nor Send the DB Channel Post link", chat_id = message.from_user.id, filters=(filters.forwarded | (filters.text & ~filters.forwarded)), timeout=60)
26 | except:
27 | return
28 | s_msg_id = await get_message_id(client, second_message)
29 | if s_msg_id:
30 | break
31 | else:
32 | await second_message.reply("❌ Error\n\nthis Forwarded Post is not from my DB Channel or this Link is taken from DB Channel", quote = True)
33 | continue
34 |
35 |
36 | string = f"get-{f_msg_id * abs(client.db_channel.id)}-{s_msg_id * abs(client.db_channel.id)}"
37 | base64_string = await encode(string)
38 | link = f"https://t.me/{client.username}?start={base64_string}"
39 | reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("🔁 Share URL", url=f'https://telegram.me/share/url?url={link}')]])
40 | await second_message.reply_text(f"Here is your link\n\n{link}", quote=True, reply_markup=reply_markup)
41 |
42 |
43 | @Bot.on_message(filters.private & filters.user(ADMINS) & filters.command('genlink'))
44 | async def link_generator(client: Client, message: Message):
45 | while True:
46 | try:
47 | channel_message = await client.ask(text = "Forward Message from the DB Channel (with Quotes)..\nor Send the DB Channel Post link", chat_id = message.from_user.id, filters=(filters.forwarded | (filters.text & ~filters.forwarded)), timeout=60)
48 | except:
49 | return
50 | msg_id = await get_message_id(client, channel_message)
51 | if msg_id:
52 | break
53 | else:
54 | await channel_message.reply("❌ Error\n\nthis Forwarded Post is not from my DB Channel or this Link is not taken from DB Channel", quote = True)
55 | continue
56 |
57 | base64_string = await encode(f"get-{msg_id * abs(client.db_channel.id)}")
58 | link = f"https://t.me/{client.username}?start={base64_string}"
59 | reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("🔁 Share URL", url=f'https://telegram.me/share/url?url={link}')]])
60 | await channel_message.reply_text(f"Here is your link\n\n{link}", quote=True, reply_markup=reply_markup)
61 |
--------------------------------------------------------------------------------
/plugins/route.py:
--------------------------------------------------------------------------------
1 | from aiohttp import web
2 |
3 | routes = web.RouteTableDef()
4 |
5 | @routes.get("/", allow_head=True)
6 | async def root_route_handler(request):
7 | return web.json_response("CodeXBotz")
8 |
--------------------------------------------------------------------------------
/plugins/start.py:
--------------------------------------------------------------------------------
1 | #(©)CodeXBotz
2 | import asyncio
3 | import base64
4 | import logging
5 | import os
6 | import random
7 | import re
8 | import string
9 | import time
10 |
11 | from pyrogram import Client, filters, __version__
12 | from pyrogram.enums import ParseMode
13 | from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
14 | from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated
15 |
16 | from bot import Bot
17 | from config import (
18 | ADMINS,
19 | FORCE_MSG,
20 | START_MSG,
21 | CUSTOM_CAPTION,
22 | IS_VERIFY,
23 | VERIFY_EXPIRE,
24 | SHORTLINK_API,
25 | SHORTLINK_URL,
26 | DISABLE_CHANNEL_BUTTON,
27 | PROTECT_CONTENT,
28 | TUT_VID,
29 | OWNER_ID,
30 | )
31 | from helper_func import subscribed, encode, decode, get_messages, get_shortlink, get_verify_status, update_verify_status, get_exp_time
32 | from database.database import add_user, del_user, full_userbase, present_user
33 | from shortzy import Shortzy
34 |
35 | @Bot.on_message(filters.command('start') & filters.private & subscribed)
36 | async def start_command(client: Client, message: Message):
37 | id = message.from_user.id
38 | owner_id = ADMINS # Fetch the owner's ID from config
39 |
40 | # Check if the user is the owner
41 | if id == owner_id:
42 | # Owner-specific actions
43 | # You can add any additional actions specific to the owner here
44 | await message.reply("You are the owner! Additional actions can be added here.")
45 |
46 | else:
47 | if not await present_user(id):
48 | try:
49 | await add_user(id)
50 | except:
51 | pass
52 |
53 | verify_status = await get_verify_status(id)
54 | if verify_status['is_verified'] and VERIFY_EXPIRE < (time.time() - verify_status['verified_time']):
55 | await update_verify_status(id, is_verified=False)
56 |
57 | if "verify_" in message.text:
58 | _, token = message.text.split("_", 1)
59 | if verify_status['verify_token'] != token:
60 | return await message.reply("Your token is invalid or Expired. Try again by clicking /start")
61 | await update_verify_status(id, is_verified=True, verified_time=time.time())
62 | if verify_status["link"] == "":
63 | reply_markup = None
64 | await message.reply(f"Your token successfully verified and valid for: 24 Hour", reply_markup=reply_markup, protect_content=False, quote=True)
65 |
66 | elif len(message.text) > 7 and verify_status['is_verified']:
67 | try:
68 | base64_string = message.text.split(" ", 1)[1]
69 | except:
70 | return
71 | _string = await decode(base64_string)
72 | argument = _string.split("-")
73 | if len(argument) == 3:
74 | try:
75 | start = int(int(argument[1]) / abs(client.db_channel.id))
76 | end = int(int(argument[2]) / abs(client.db_channel.id))
77 | except:
78 | return
79 | if start <= end:
80 | ids = range(start, end+1)
81 | else:
82 | ids = []
83 | i = start
84 | while True:
85 | ids.append(i)
86 | i -= 1
87 | if i < end:
88 | break
89 | elif len(argument) == 2:
90 | try:
91 | ids = [int(int(argument[1]) / abs(client.db_channel.id))]
92 | except:
93 | return
94 | temp_msg = await message.reply("Please wait...")
95 | try:
96 | messages = await get_messages(client, ids)
97 | except:
98 | await message.reply_text("Something went wrong..!")
99 | return
100 | await temp_msg.delete()
101 |
102 | for msg in messages:
103 | if bool(CUSTOM_CAPTION) & bool(msg.document):
104 | caption = CUSTOM_CAPTION.format(previouscaption="" if not msg.caption else msg.caption.html, filename=msg.document.file_name)
105 | else:
106 | caption = "" if not msg.caption else msg.caption.html
107 |
108 | if DISABLE_CHANNEL_BUTTON:
109 | reply_markup = msg.reply_markup
110 | else:
111 | reply_markup = None
112 |
113 | try:
114 | await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, reply_markup=reply_markup, protect_content=PROTECT_CONTENT)
115 | await asyncio.sleep(0.5)
116 | except FloodWait as e:
117 | await asyncio.sleep(e.x)
118 | await msg.copy(chat_id=message.from_user.id, caption=caption, parse_mode=ParseMode.HTML, reply_markup=reply_markup, protect_content=PROTECT_CONTENT)
119 | except:
120 | pass
121 |
122 | elif verify_status['is_verified']:
123 | reply_markup = InlineKeyboardMarkup(
124 | [[InlineKeyboardButton("About Me", callback_data="about"),
125 | InlineKeyboardButton("Close", callback_data="close")]]
126 | )
127 | await message.reply_text(
128 | text=START_MSG.format(
129 | first=message.from_user.first_name,
130 | last=message.from_user.last_name,
131 | username=None if not message.from_user.username else '@' + message.from_user.username,
132 | mention=message.from_user.mention,
133 | id=message.from_user.id
134 | ),
135 | reply_markup=reply_markup,
136 | disable_web_page_preview=True,
137 | quote=True
138 | )
139 |
140 | else:
141 | verify_status = await get_verify_status(id)
142 | if IS_VERIFY and not verify_status['is_verified']:
143 | short_url = f"api.shareus.io"
144 | full_tut_url = f"https://t.me/neprosz/3"
145 | token = ''.join(random.choices(string.ascii_letters + string.digits, k=10))
146 | await update_verify_status(id, verify_token=token, link="")
147 | link = await get_shortlink(SHORTLINK_URL, SHORTLINK_API,f'https://telegram.dog/{client.username}?start=verify_{token}')
148 | btn = [
149 | [InlineKeyboardButton("Click here", url=link)],
150 | [InlineKeyboardButton('How to use the bot', url=full_tut_url)]
151 | ]
152 | await message.reply(f"Your Ads token is expired, refresh your token and try again.\n\nToken Timeout: {get_exp_time(VERIFY_EXPIRE)}\n\nWhat is the token?\n\nThis is an ads token. If you pass 1 ad, you can use the bot for 24 Hour after passing the ad.", reply_markup=InlineKeyboardMarkup(btn), protect_content=False, quote=True)
153 |
154 | # ... (rest of the code remains unchanged))
155 |
156 |
157 |
158 |
159 | #=====================================================================================##
160 |
161 | WAIT_MSG = """"Processing ..."""
162 |
163 | REPLY_ERROR = """Use this command as a replay to any telegram message with out any spaces.
"""
164 |
165 | #=====================================================================================##
166 |
167 |
168 |
169 | @Bot.on_message(filters.command('start') & filters.private)
170 | async def not_joined(client: Client, message: Message):
171 | buttons = [
172 | [
173 | InlineKeyboardButton(
174 | "Join Channel",
175 | url = client.invitelink)
176 | ]
177 | ]
178 | try:
179 | buttons.append(
180 | [
181 | InlineKeyboardButton(
182 | text = 'Try Again',
183 | url = f"https://t.me/{client.username}?start={message.command[1]}"
184 | )
185 | ]
186 | )
187 | except IndexError:
188 | pass
189 |
190 | await message.reply(
191 | text = FORCE_MSG.format(
192 | first = message.from_user.first_name,
193 | last = message.from_user.last_name,
194 | username = None if not message.from_user.username else '@' + message.from_user.username,
195 | mention = message.from_user.mention,
196 | id = message.from_user.id
197 | ),
198 | reply_markup = InlineKeyboardMarkup(buttons),
199 | quote = True,
200 | disable_web_page_preview = True
201 | )
202 |
203 | @Bot.on_message(filters.command('users') & filters.private & filters.user(ADMINS))
204 | async def get_users(client: Bot, message: Message):
205 | msg = await client.send_message(chat_id=message.chat.id, text=WAIT_MSG)
206 | users = await full_userbase()
207 | await msg.edit(f"{len(users)} users are using this bot")
208 |
209 | @Bot.on_message(filters.private & filters.command('broadcast') & filters.user(ADMINS))
210 | async def send_text(client: Bot, message: Message):
211 | if message.reply_to_message:
212 | query = await full_userbase()
213 | broadcast_msg = message.reply_to_message
214 | total = 0
215 | successful = 0
216 | blocked = 0
217 | deleted = 0
218 | unsuccessful = 0
219 |
220 | pls_wait = await message.reply("Broadcasting Message.. This will Take Some Time")
221 | for chat_id in query:
222 | try:
223 | await broadcast_msg.copy(chat_id)
224 | successful += 1
225 | except FloodWait as e:
226 | await asyncio.sleep(e.x)
227 | await broadcast_msg.copy(chat_id)
228 | successful += 1
229 | except UserIsBlocked:
230 | await del_user(chat_id)
231 | blocked += 1
232 | except InputUserDeactivated:
233 | await del_user(chat_id)
234 | deleted += 1
235 | except:
236 | unsuccessful += 1
237 | pass
238 | total += 1
239 |
240 | status = f"""Broadcast Completed
241 |
242 | Total Users: {total}
243 | Successful: {successful}
244 | Blocked Users: {blocked}
245 | Deleted Accounts: {deleted}
246 | Unsuccessful: {unsuccessful}
"""
247 |
248 | return await pls_wait.edit(status)
249 |
250 | else:
251 | msg = await message.reply(REPLY_ERROR)
252 | await asyncio.sleep(8)
253 | await msg.delete()
254 |
--------------------------------------------------------------------------------
/plugins/useless.py:
--------------------------------------------------------------------------------
1 | from bot import Bot
2 | from pyrogram.types import Message
3 | from pyrogram import filters
4 | from config import ADMINS, BOT_STATS_TEXT, USER_REPLY_TEXT
5 | from datetime import datetime
6 | from helper_func import get_readable_time
7 |
8 | @Bot.on_message(filters.command('stats') & filters.user(ADMINS))
9 | async def stats(bot: Bot, message: Message):
10 | now = datetime.now()
11 | delta = now - bot.uptime
12 | time = get_readable_time(delta.seconds)
13 | await message.reply(BOT_STATS_TEXT.format(uptime=time))
14 |
15 |
16 | @Bot.on_message(filters.private & filters.incoming)
17 | async def useless(_,message: Message):
18 | if USER_REPLY_TEXT:
19 | await message.reply(USER_REPLY_TEXT)
20 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | # --- For-Bot-Working --------- #
2 | pyrogram
3 | TgCrypto
4 | pyromod
5 | # --- For-Database ------------ #
6 | pymongo
7 | motor
8 | umongo
9 | dnspython
10 | marshmallow
11 | # --- For-Web-Response ------- #
12 | pytz
13 | requests
14 | bs4
15 | shortzy
16 | aiohttp
17 | aiofiles
18 | asyncio
19 |
--------------------------------------------------------------------------------