@pool.run_in_thread def _transcode(input_: str) -> str: output = "output.raw" ffmpeg.input(input_).output( output, format='s16le', acodec='pcm_s16le', ac=2, ar='48k' ).overwrite_output().run() return output if userge.has_bot: @userge.bot.on_callback_query(filters.regex("(skip|queue|back)")) @check_cq_for_all async def vc_callback(cq: CallbackQuery): if not CHAT_NAME: await cq.edit_message_text("`Already Left Voice-Call`") return if "skip" in cq.data: text = f"{cq.from_user.mention} Skipped the Song." pattern = re.compile(r'\[(.*)\]') name = None for match in pattern.finditer(BACK_BUTTON_TEXT): name = match.group(1) break if name: text = f"{cq.from_user.mention} Skipped `{name}`."
@userge.on_filters(~allowAllFilter & filters.outgoing & filters.private & ~pmpermit.ALLOWED_CHATS, allow_via_bot=False) async def outgoing_auto_approve(message: Message): """ outgoing handler """ userID = message.chat.id if userID in pmCounter: del pmCounter[userID] pmpermit.ALLOWED_CHATS.add(userID) await ALLOWED_COLLECTION.update_one( {'_id': userID}, {"$set": {'status': 'allowed'}}, upsert=True) user_dict = await userge.get_user_dict(userID) await CHANNEL.log(f"**#AUTO_APPROVED**\n{user_dict['mention']}") if userge.has_bot: @userge.bot.on_callback_query(filters.regex(pattern=r"pm_allow\((.+?)\)")) async def pm_callback_allow(_, c_q: CallbackQuery): owner = await userge.get_me() if c_q.from_user.id == owner.id: userID = int(c_q.matches[0].group(1)) await userge.unblock_user(userID) user = await userge.get_users(userID) if userID in pmpermit.ALLOWED_CHATS: await c_q.edit_message_text( f"{user.mention} already allowed to Direct Messages.") else: await c_q.edit_message_text( f"{user.mention} allowed to Direct Messages.") await userge.send_message( userID, f"{owner.mention} `approved you to Direct Messages.`") if userID in pmCounter:
SET_CUSTOM_TEXT = """You can set Custom Start text which you will see when you start Bot by /settext command. """ HELP_TEXT = """**Here are the available commands for Bot PM:** /start - Start the bot /help -See this text again /settext [text | reply to text] - Set Custom Start Text /pmban [user_id | reply to user] - Ban User from Doing Pms /pmunban [user_id | reply to user] - UnBan Banned user """ @bot.on_callback_query( filters.regex( "startcq|stngs|bothelp|misc|setmedia|settext|broadcast|stats|en_dis_bot_pm" )) async def cq_handler(_, cq: CallbackQuery): global BOT_PM, IN_CONVO # pylint: disable=global-statement settings_markup = InlineKeyboardMarkup( [[ InlineKeyboardButton("Broadcast", callback_data="broadcast"), InlineKeyboardButton("Statistics", callback_data="stats") ], [ InlineKeyboardButton("Misc", callback_data="misc"), InlineKeyboardButton("Help", callback_data="bothelp") ], [InlineKeyboardButton("Back", callback_data="startcq")]]) if cq.data == "stngs": text = f"Bot Pm - {'Disabled ❌' if not BOT_PM else 'Enabled ✅'}" btn = [InlineKeyboardButton(text, callback_data="en_dis_bot_pm")]
After Adding a var, you can see your media when you start your Bot. """ SET_CUSTOM_TEXT = """You can set Custom Start text which you will see when you start Bot by /settext command. """ HELP_TEXT = """**Here are the available commands for Bot PM:** /start - Start the bot /settext [text | reply to text] - Set Custom Start Text /pmban [user_id | reply to user] - Ban User from Doing Pms /pmunban [user_id | reply to user] - UnBan Banned user """ @bot.on_callback_query(filters.regex( "startcq|stngs|bothelp|misc|setmedia|settext|broadcast|stats|en_dis_bot_pm" ), group=1) async def cq_handler(_, cq: CallbackQuery): global BOT_PM, IN_CONVO # pylint: disable=global-statement settings_markup = InlineKeyboardMarkup( [[ InlineKeyboardButton("Broadcast", callback_data="broadcast"), InlineKeyboardButton("Statistics", callback_data="stats") ], [ InlineKeyboardButton("Misc", callback_data="misc"), InlineKeyboardButton("Help", callback_data="bothelp") ], [InlineKeyboardButton("Back", callback_data="startcq")]]) if cq.data == "stngs": text = f"Bot Pm - {'Disabled ❌' if not BOT_PM else 'Enabled ✅'}"
@pool.run_in_thread def _transcode(input_: str) -> str: output = "output.raw" ffmpeg.input(input_).output(output, format="s16le", acodec="pcm_s16le", ac=2, ar="48k").overwrite_output().run() return output if userge.has_bot: @userge.bot.on_callback_query(filters.regex("(skip|queue|back)")) async def vc_callback(_, cq: CallbackQuery): global CQ_MSG # pylint: disable=global-statement if not CHAT_NAME: await cq.edit_message_text("`Already Left Voice-Call`") return if "skip" in cq.data: if not ADMINS or not ADMINS.get(cq.message.chat.id): await cache_admins(cq.message.chat.id) if cq.from_user.id not in ADMINS[cq.message.chat.id]: return await cq.answer("Only Admins can Skip Song.") text = f"{cq.from_user.mention} Skipped this Song." pattern = re.compile(r"\((.*)\)")
@pool.run_in_thread def _get_song_info(url: str): ydl_opts = {} with ytdl.YoutubeDL(ydl_opts) as ydl: info = ydl.extract_info(url, download=False) duration = info.get("duration") or 0 if duration > video_chat.MAX_DURATION: return False return info.get("title"), duration if duration else 0 if userge.has_bot: @userge.bot.on_callback_query(filters.regex("(skip|queue|back$)")) @check_cq_for_all async def vc_callback(cq: CallbackQuery): await cq.answer() if not CHAT_NAME: await cq.edit_message_text("`Already Left Video-Chat`") return if "skip" in cq.data: text = f"{cq.from_user.mention} Skipped the Song." pattern = re.compile(r'\[(.*)\]') name = None for match in pattern.finditer(BACK_BUTTON_TEXT): name = match.group(1) break if name:
await on_join(group_call.call) elif participant.left: await on_left(group_call.call) break raise ContinuePropagation @call.on_stream_end() async def _stream_end_handler(_: PyTgCalls, update: Update): if isinstance(update, StreamAudioEnded): Dynamic.PLAYING = False await skip_song() @call.on_participants_change() async def _participants_change_handler(_: PyTgCalls, update: Update): if isinstance(update, JoinedGroupCallParticipant): GROUP_CALL_PARTICIPANTS.append(update.participant.user_id) elif isinstance(update, LeftGroupCallParticipant): GROUP_CALL_PARTICIPANTS.remove(update.participant.user_id) if userge.has_bot: userge.bot.add_handler( CallbackQueryHandler(vc_callback, filters.regex("(skip|queue|back$)"))) userge.bot.add_handler( CallbackQueryHandler(vol_callback, filters.regex(r"vol\((.+)\)"))) userge.bot.add_handler( CallbackQueryHandler(vc_control_callback, filters.regex("(player|seek|rewind|replay)")))
user_id, flname, msg = PRVT_MSGS[msg_id] # redundant conditional check, to HP UBs if message.from_user.id == user_id or message.from_user.id in config.OWNER_ID: if msg["file_id"] != "0": await message.reply_cached_media(msg["file_id"], caption=msg["caption"], parse_mode="html") else: await message.reply_text(msg["caption"], parse_mode="html") else: await message.reply(f"only {flname} can see this Private Msg!") message.stop_propagation() @userge.bot.on_callback_query(filters=filters.regex(pattern=r"prvtmsg\((.+)\)") ) async def prvt_msg(_, c_q: CallbackQuery): msg_id = str(c_q.matches[0].group(1)) if msg_id not in PRVT_MSGS: await c_q.answer("message now outdated !", show_alert=True) return bot_username = (await userge.bot.get_me()).username user_id, flname, msg = PRVT_MSGS[msg_id] if c_q.from_user.id == user_id or c_q.from_user.id in config.OWNER_ID: if isinstance(msg, str): await c_q.answer(msg, show_alert=True)
LOG = userge.getLogger(__name__) CHANNEL = userge.getCLogger(__name__) AFK = [] FIX = "" FK = "" CHAT = [-1001199769918, -1001360580171, -1001486172777] # rdl WW = [1029642148, 980444671, 618096097, 175844556, 738172950, 1569645653] # werewolf bots @userge.on_filters( ( filters.chat(CHAT) & filters.user(WW) & filters.regex("Tempo total do jogo|Duração da partida") ) ) async def auto_fk(message: Message): global AFK global FK if await is_sr(message): FK = "" return lines = message.text lines_count = len(lines.split("\n\n")[0].split("\n")) - 1 info = await userge.send_message(message.chat.id, "Obtendo FK.") try: deads = await build_list(lines) deads = [dead for dead in deads if dead not in AFK] output = await order_fk(deads, lines_count)