Initial commit

This commit is contained in:
2022-04-02 22:03:41 +03:00
commit edada2a968
4 changed files with 53 additions and 0 deletions

34
grab_samples.py Normal file
View File

@@ -0,0 +1,34 @@
import os
from dotenv import load_dotenv
from telethon.sync import TelegramClient
load_dotenv()
api_id = os.getenv('API_ID')
api_hash = os.getenv('API_HASH')
chat = 'tg1337const'
def cleanup(msg):
unwanted_strings = [
'[1337const | подписаться](https://t.me/tg1337const)',
'[1337const | Подписаться](https://t.me/tg1337const)'
]
try:
for unwanted in unwanted_strings:
msg = msg.replace(unwanted, '')
return msg
except:
return msg
with TelegramClient('session_name', api_id, api_hash) as client:
f = open("data/data.txt", "w")
for message in client.iter_messages(chat):
try:
f.write(cleanup(message.text))
except:
pass
f.close()