75 lines
2.1 KiB
Python
75 lines
2.1 KiB
Python
|
|
import asyncio
|
|
import json
|
|
import logging
|
|
import os
|
|
|
|
from dotenv import load_dotenv
|
|
from pyrogram import Client
|
|
|
|
from steam_parser.steam import SteamLogin
|
|
from utils.strings import parse_post
|
|
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
|
handlers=[
|
|
logging.FileHandler("steam_guard.log", encoding='utf-8'),
|
|
logging.StreamHandler()
|
|
]
|
|
)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
load_dotenv()
|
|
|
|
API_ID = os.getenv('API_ID')
|
|
API_HASH = os.getenv('API_HASH')
|
|
CHANNEL_URL = os.getenv('CHANNEL_URL')
|
|
|
|
|
|
async def fetch_and_monitor_accounts():
|
|
client = Client(
|
|
name='pyrogram_session',
|
|
api_id=API_ID,
|
|
api_hash=API_HASH
|
|
)
|
|
|
|
channel_name = os.path.basename(CHANNEL_URL)
|
|
|
|
await client.start()
|
|
|
|
processed_messages = set() # Хранение ID обработанных сообщений
|
|
|
|
while True:
|
|
accounts = []
|
|
async for message in client.get_chat_history(channel_name, limit=200):
|
|
text = message.text or message.caption
|
|
if text and message.id not in processed_messages:
|
|
pairs = parse_post(text)
|
|
for login, password in pairs:
|
|
accounts.append({
|
|
'username': login,
|
|
'password': password,
|
|
'date': message.date.isoformat()
|
|
})
|
|
processed_messages.add(message.id)
|
|
|
|
if accounts:
|
|
# Сортируем по дате (от новых к старым)
|
|
accounts.sort(key=lambda x: x['date'], reverse=True)
|
|
top_50 = accounts[:50]
|
|
|
|
with open('credentials.json', 'w', encoding='utf-8') as f:
|
|
json.dump({'accounts': top_50}, f, indent=4, ensure_ascii=False)
|
|
|
|
logger.info(f"\n✅ Сохранено {len(top_50)} аккаунтов в credentials.json")
|
|
|
|
SteamLogin().open_steam_login_page_and_type()
|
|
|
|
await asyncio.sleep(30)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(fetch_and_monitor_accounts())
|
|
# asyncio.run(SteamLogin().open_steam_login_page_and_type()) |