Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from telethon import TelegramClient, events
- from telethon.tl.types import MessageEntityTextUrl
- api_id = 0000000 #
- api_hash = "*******"
- client = TelegramClient("Video", api_id, api_hash)
- target_can = -10000000000 # id каналу в який будуть пересилатись новини
- client.parse_mode = "html"
- @client.on(events.NewMessage(chats=[-10000000000]))
- async def normal_handler(event):
- print("**************************************************")
- if event.message.peer_id != target_can:
- if not event.message.is_private and not event.message.is_reply:
- print(event.message.peer_id)
- mess = event.message
- for i in range(len(mess.entities) - 1):
- try:
- print(len(mess.entities))
- print(mess.get_entities_text(MessageEntityTextUrl)[i])
- if isinstance(mess.entities[i], MessageEntityTextUrl):
- entity = mess.entities[i]
- print(entity)
- new_text = "!!!Новий текст!!!" # текст під яким буде заховано посилання
- entity.length = len(new_text)
- entity.url = (
- "https://t.me/+JJJJJJJJJJJJ" # писилання з підпису
- )
- mess.message = mess.message.replace(
- mess.get_entities_text(MessageEntityTextUrl)[i][1],
- "!!!Новий текст!!!!", # текст під яким буде заховано посилання
- )
- print(entity)
- except Exception as e:
- print(e)
- await client.send_message(target_can, mess, parse_mode="html")
- client.start(password="00000000000")
- client.run_until_disconnected()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement