-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.py
32 lines (26 loc) · 1.06 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys
import os
from pyrogram import Client, filters
from src.AppConfig import AppConfig
from src.LogHelper import Logger
from src.telegram_client import TelegramClient
app_config = AppConfig()
app = Client(app_config.session, app_config.api_id, app_config.api_hash)
telegram_client = TelegramClient(app)
from_chats = telegram_client.get_formatted_chats(app_config.from_chats)
Logger.info(f"From chats - {from_chats}")
to_chats = telegram_client.get_formatted_chats(app_config.to_chats)
Logger.info(f"To chats - {to_chats}")
@app.on_message(filters.chat(from_chats) & filters.incoming)
def run(client, message):
Logger.info(f"Message Incoming - from {message.sender_chat.id, message.sender_chat.title}")
try:
for chat in to_chats:
# Logger.info(message)
if not message.chat.has_protected_content:
message.forward(chat)
else:
app.send_message(chat_id=chat, text = [message.sender_chat.id, message.sender_chat.title, message.text])
except Exception as e:
Logger.error(e)
app.run()