def checkban():
while True:
for event in longpoll.listen():
try:
if event.from_chat == True and event.from_me == False:
dey = event.message.action['type']
invite_id = event.message.action['member_id']
dey = ''
invite_id = -100
if dey == 'chat_ivite_user':
with open("banlist.txt", "a") as CheckBanUsers:
id = CheckBanUsers.readlines()
if int(invite_id) in id:
send(event.chat_id, "⚠ Вы в блокировке.")
vk_session.method("messages.removeChatUser", {"chat_id": event.chat_id, "user_id": event.user_id})
except Exception as error:
print(error)
with open("banlist.txt", "a") as CheckBanUsers:
id = CheckBanUsers.readlines()
a
открыт, если нужно прочитать с него что-то?readlines
оставит символы переноса строкwith open("banlist.txt", "r") as CheckBanUsers:
banned_ids = f.read().splitlines()
if str(invite_id) in banned_ids:
['1212\n', '12323\n', '3434']
# db.txt
1212
12323
3434
# main.py
with open ('db.txt', 'r', encoding='UTF-8') as file:
lines = file.readlines()
if str(3434) in lines:
print('ok')
else:
print(lines)