async def pre_check(_: Client, msg: Message) -> None: if msg.text and msg.text.startswith("/start"): return if msg.from_user.id not in get_whitelist(): await msg.reply("駭客喵喵還不認識你喔,請跟我講通關密語或等到公開測試") msg.stop_propagation()
async def globalFloodPrevention(client: lolBot, message: Message): if message.from_user.id in users: message.stop_propagation() users.append(message.from_user.id) t = threading.Thread(target=handleFlood, args=(message.from_user.id, ), daemon=True) t.start() message.continue_propagation()
async def stop_user_from_doing_anything(_, message: Message): allowed_users = Common().allowed_users if allowed_users: if message.chat.id in allowed_users or message.chat.id == Common( ).bot_dustbin: message.continue_propagation() else: message.stop_propagation() else: message.continue_propagation()
async def recv_tg_code_message(_, message: Message): w_s_dict = AKTIFPERINTAH.get(message.chat.id) if not w_s_dict: return sent_code = w_s_dict.get("SENT_CODE_R") phone_number = w_s_dict.get("PHONE_NUMBER") loical_ci = w_s_dict.get("USER_CLIENT") if not sent_code or not phone_number: return status_message = w_s_dict.get("MESSAGE") if not status_message: return # await status_message.delete() del w_s_dict["MESSAGE"] status_message = await message.reply_text(RECVD_PHONE_CODE) phone_code = "".join(message.text.split(" ")) try: w_s_dict["SIGNED_IN"] = await loical_ci.sign_in( phone_number, sent_code.phone_code_hash, phone_code) except BadRequest as e: await status_message.edit_text(e.MESSAGE + "\n\n" + PHONE_CODE_IN_VALID_ERR_TEXT) del AKTIFPERINTAH[message.chat.id] except SessionPasswordNeeded: await status_message.edit_text(ACC_PROK_WITH_TFA) w_s_dict["IS_NEEDED_TFA"] = True else: saved_message_ = await status_message.edit_text( "<code>" + str(await loical_ci.export_session_string()) + "</code>") await saved_message_.reply_text(SESSION_GENERATED_USING, quote=True) del AKTIFPERINTAH[message.chat.id] return False AKTIFPERINTAH[message.chat.id] = w_s_dict raise message.stop_propagation()
async def recv_tg_tfa_message(_, message: Message): w_s_dict = AKTIFPERINTAH.get(message.chat.id) if not w_s_dict: return phone_number = w_s_dict.get("PHONE_NUMBER") loical_ci = w_s_dict.get("USER_CLIENT") is_tfa_reqd = bool(w_s_dict.get("IS_NEEDED_TFA")) if not is_tfa_reqd or not phone_number: return tfa_code = message.text try: await loical_ci.check_password(tfa_code) except PasswordHashInvalid: await message.reply_text( TFA_CODE_IN_VALID_ERR_TEXT ) del AKTIFPERINTAH[message.chat.id] else: saved_message_ = await message.reply_text( "<code>" + str(await loical_ci.export_session_string()) + "</code>" ) await saved_message_.reply_text( SESSION_GENERATED_USING, quote=True ) raise message.stop_propagation()
async def stop_user_from_doing_anything(_, message: Message): """ Checks if user is allowed to use MediaCenterBot """ # Updates user details if they are supposed to be in the system if message.from_user.id in UserDB().all_user_ids(): UserDB().update_user(message) pass if message.from_user.id not in UserDB().all_user_ids(): if message.chat and message.chat.type in {"group", "supergroup"}: await message.reply(GROUPS_NOT_ALLOWED_MESSAGE) Incident().create_incident(message) message.stop_propagation() else: await message.reply(NOT_ALLOWED_MESSAGE) Incident().create_incident(message) message.stop_propagation() else: message.continue_propagation()
async def bot_prvtmsg_start_dl(_, message: PyroMessage): msg_id = message.text[14:] if msg_id not in PRVT_MSGS: await message.reply("message not found!") message.stop_propagation() return 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()
async def recvd_ph_no_message(_, message: Message): w_s_dict = AKTIFPERINTAH.get(message.chat.id) if not w_s_dict: return status_message = w_s_dict.get("START") if not status_message: return # await w_s_dict.get("START").delete() del w_s_dict["START"] status_message = await message.reply_text(RECVD_PHONE_NUMBER_DBP) loical_ci = User() w_s_dict["PHONE_NUMBER"] = message.text await loical_ci.connect() w_s_dict["SENT_CODE_R"] = await loical_ci.send_code( w_s_dict["PHONE_NUMBER"]) w_s_dict["USER_CLIENT"] = loical_ci status_message = await status_message.edit_text( ALREADY_REGISTERED_PHONE + "\n\n" + CONFIRM_SENT_VIA.format( AVAILABLE_CODE_RECVING_OPTIONS[w_s_dict["SENT_CODE_R"].type])) w_s_dict["MESSAGE"] = status_message AKTIFPERINTAH[message.chat.id] = w_s_dict raise message.stop_propagation()
async def stop_user_from_doing_anything(_, message: Message): allowed_users = Common().allowed_users if allowed_users and message.from_user.id not in allowed_users: message.stop_propagation() else: message.continue_propagation()
async def fuck_groups(_, message: Message): """ Needed to plop this somewhere """ message.stop_propagation()
async def num_start_message(_, message: Message): AKTIFPERINTAH[message.chat.id] = {} status_message = await message.reply_text(START_OTHER_USERS_TEXT + "\n" + INPUT_PHONE_NUMBER) AKTIFPERINTAH[message.chat.id]["START"] = status_message raise message.stop_propagation()
async def reject(c: Client, m: Message): m.stop_propagation()
async def reject_edited(c: Korone, m: Message): m.stop_propagation()
async def edited(bot: Amime, message: Message): message.stop_propagation()