MCPcopy Create free account
hub / github.com/TechifyBots/File-Stream-Bot / channel_receive_handler

Function channel_receive_handler

biisal/bot/plugins/stream.py:142–184  ·  view source on GitHub ↗
(bot, broadcast)

Source from the content-addressed store, hash-verified

140
141@StreamBot.on_message(filters.channel & ~filters.group & (filters.document | filters.video | filters.photo) & ~filters.forwarded, group=-1)
142async def channel_receive_handler(bot, broadcast):
143 if int(broadcast.chat.id) in Var.BAN_CHNL:
144 print("chat trying to get straming link is found in BAN_CHNL,so im not going to give stram link")
145 return
146 ban_chk = await db.is_banned(int(broadcast.chat.id))
147 if (int(broadcast.chat.id) in Var.BANNED_CHANNELS) or (ban_chk == True):
148 await bot.leave_chat(broadcast.chat.id)
149 return
150 try: # This is the outer try block
151 log_msg = await broadcast.forward(chat_id=Var.BIN_CHANNEL)
152 stream_link = f"{Var.URL}watch/{str(log_msg.id)}/{quote_plus(get_name(log_msg))}?hash={get_hash(log_msg)}"
153 online_link = f"{Var.URL}{str(log_msg.id)}/{quote_plus(get_name(log_msg))}?hash={get_hash(log_msg)}"
154 try: # This is the inner try block
155 if Var.SHORTLINK:
156 stream = get_shortlink(stream_link)
157 download = get_shortlink(online_link)
158 else:
159 stream = stream_link
160 download = online_link
161 except Exception as e:
162 print(f"An error occurred: {e}")
163
164 await log_msg.reply_text(
165 text=f"**Channel Name:** `{broadcast.chat.title}`\n**CHANNEL ID:** `{broadcast.chat.id}`\n**Rᴇǫᴜᴇsᴛ ᴜʀʟ:** {stream_link}",
166 quote=True
167 )
168 await bot.edit_message_reply_markup(
169 chat_id=broadcast.chat.id,
170 message_id=broadcast.id,
171 reply_markup=InlineKeyboardMarkup([
172 [InlineKeyboardButton("ꜱᴛʀᴇᴀᴍ 🔺", url=stream),
173 InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ 🔻", url=download)]
174 ])
175 )
176 except FloodWait as w:
177 print(f"Sleeping for {str(w.x)}s")
178 await asyncio.sleep(w.x)
179 await bot.send_message(chat_id=Var.BIN_CHANNEL,
180 text=f"GOT FLOODWAIT OF {str(w.x)}s FROM {broadcast.chat.title}\n\n**CHANNEL ID:** `{str(broadcast.chat.id)}`",
181 disable_web_page_preview=True)
182 except Exception as e:
183 await bot.send_message(chat_id=Var.BIN_CHANNEL, text=f"**#ERROR_TRACKEBACK:** `{e}`", disable_web_page_preview=True)
184 print(f"Cᴀɴ'ᴛ Eᴅɪᴛ Bʀᴏᴀᴅᴄᴀsᴛ Mᴇssᴀɢᴇ!\nEʀʀᴏʀ: **Give me edit permission in updates and bin Channel!{e}**")

Callers

nothing calls this directly

Calls 4

get_nameFunction · 0.90
get_hashFunction · 0.90
get_shortlinkFunction · 0.85
is_bannedMethod · 0.80

Tested by

no test coverage detected