forked from AkkilMG/Feedback-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
156 lines (127 loc) · 5.3 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Copyright (c) 2021 HEIMAN PICTURES
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from pyrogram import Client, filters
import logging
from configs import Config as C
# LMAO, This Is Logging
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
logging.getLogger("pyrogram").setLevel(logging.WARNING)
# Import From Framework
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
# Don't Change Anything, Except If You Want To Add Value
bot = Client('Feedback bot',
api_id=C.API_ID,
api_hash=C.API_HASH,
bot_token=C.BOT_TOKEN)
donate_link=C.DONATE_LINK
owner_id=C.OWNER_ID
LOG_TEXT = "ID: <code>{}</code>\nFirst Name: <a href='tg://user?id={}'>{}{}</a>\nDC ID: <code>{}</code>"
IF_TEXT = "<b>Message from:</b> {}\n<b>Name:</b> {}\n\n{}"
IF_CONTENT = "<b>Message from:</b> {} \n<b>Name:</b> {}"
@bot.on_message(filters.command('start') & filters.private)
async def start(bot, message):
await bot.send_message(
chat_id=owner_id,
text=LOG_TEXT.format(message.chat.id,message.chat.id,message.chat.first_name,message.chat.last_name,message.chat.dc_id),
parse_mode="html"
)
await message.reply_text(
text="**Hi {}!**\n".format(message.chat.first_name)+C.START,
reply_markup=InlineKeyboardMarkup([
[ InlineKeyboardButton(text="🛠SUPPORT🛠", url=f"{C.SUPPORT_GROUP}"), InlineKeyboardButton(text="📮UPDATES📮", url=f"{C.UPDATE_CHANNEL}")]
])
)
@bot.on_message(filters.command('help') & filters.private)
async def help(bot, message):
await message.reply_text(
text=C.HELP,
reply_markup=InlineKeyboardMarkup([
[ InlineKeyboardButton(text="🛠SUPPORT🛠", url=f"{C.SUPPORT_GROUP}"), InlineKeyboardButton(text="📮UPDATES📮", url=f"{C.UPDATE_CHANNEL}")]
])
)
@bot.on_message(filters.command('donate') & filters.private)
async def donate(bot, message):
await message.reply_text(
text=C.DONATE + "If You Liked This Bot You Can Also Donate Creator through BTC `3AKE4bNwb9TsgaofLQxHAGCR9w2ftwFs2R`",
reply_markup=InlineKeyboardMarkup([
[ InlineKeyboardButton(text="DONATE", url=f"{donate_link}")]
])
)
@bot.on_message(filters.private & filters.text)
async def pm_text(bot, message):
if message.from_user.id == owner_id:
await reply_text(bot, message)
return
info = await bot.get_users(user_ids=message.from_user.id)
reference_id = int(message.chat.id)
await bot.send_message(
chat_id=owner_id,
text=IF_TEXT.format(reference_id, info.first_name, message.text),
parse_mode="html"
)
@bot.on_message(filters.private & filters.media)
async def pm_media(bot, message):
if message.from_user.id == owner_id:
await replay_media(bot, message)
return
info = await bot.get_users(user_ids=message.from_user.id)
reference_id = int(message.chat.id)
await bot.copy_message(
chat_id=owner_id,
from_chat_id=message.chat.id,
message_id=message.message_id,
caption=IF_CONTENT.format(reference_id, info.first_name),
parse_mode="html"
)
@bot.on_message(filters.user(owner_id) & filters.text)
async def reply_text(bot, message):
reference_id = True
if message.reply_to_message is not None:
file = message.reply_to_message
try:
reference_id = file.text.split()[2]
except Exception:
pass
try:
reference_id = file.caption.split()[2]
except Exception:
pass
await bot.send_message(
text=message.text,
chat_id=int(reference_id)
)
@bot.on_message(filters.user(owner_id) & filters.media)
async def replay_media(bot, message):
reference_id = True
if message.reply_to_message is not None:
file = message.reply_to_message
try:
reference_id = file.text.split()[2]
except Exception:
pass
try:
reference_id = file.caption.split()[2]
except Exception:
pass
await bot.copy_message(
chat_id=int(reference_id),
from_chat_id=message.chat.id,
message_id=message.message_id,
parse_mode="html"
)
bot.run()