def auto_accept(client, message): self_user = me[0] if message.chat.id not in [self_user.id, 777000]: try: from sedenecem.sql.pm_permit_sql import approve, is_approved except BaseException: return False chat = message.chat if is_approved(chat.id): return True for msg in client.get_history(chat.id, limit=3): if chat.id in PM_LAST_MSG and msg.text != PM_LAST_MSG[ chat.id] and msg.from_user.is_self: try: del PM_COUNT[chat.id] del PM_LAST_MSG[chat.id] except BaseException: pass try: approve(chat.id) for message in _find_unapproved_msg(client, chat.id): message.delete() send_log( get_translation("pmAutoAccept", [chat.first_name, chat.id])) return True except BaseException: pass return False
def approvepm(client, message): try: from sedenecem.sql.pm_permit_sql import approve except BaseException: edit(message, f'`{get_translation("nonSqlMode")}`') return if message.reply_to_message: reply = message.reply_to_message replied_user = reply.from_user if replied_user.is_self: edit(message, f'`{get_translation("cannotApproveMyself")}`') return aname = replied_user.id name0 = str(replied_user.first_name) uid = replied_user.id else: aname = message.chat if not aname.type == 'private': edit(message, f'`{get_translation("pmApproveError")}`') return name0 = aname.first_name uid = aname.id try: approve(uid) for message in _find_unapproved_msg(client, message.chat.id): message.delete() except IntegrityError: edit(message, f'`{get_translation("pmApproveError2")}`') return edit(message, get_translation("pmApproveSuccess", [name0, uid, '`'])) send_log(get_translation("pmApproveLog", [name0, uid]))
def auto_accept(client, message): self_user = TEMP_SETTINGS['ME'] if message.chat.id not in [self_user.id, 777000]: try: from sedenecem.sql.pm_permit_sql import approve, is_approved except BaseException: return False chat = message.chat if is_approved(chat.id): return True for msg in client.get_chat_history(chat.id, limit=1): # chat.id in TEMP_SETTINGS['PM_LAST_MSG'] # and msg.text != UNAPPROVED_MSG # and if msg.from_user.id == self_user.id: try: del TEMP_SETTINGS['PM_COUNT'][chat.id] del TEMP_SETTINGS['PM_LAST_MSG'][chat.id] except BaseException: pass try: approve(chat.id) for message in _find_unapproved_msg(client, chat.id): message.delete() send_log( get_translation('pmAutoAccept', [chat.first_name, chat.id]) ) return True except BaseException: pass return False