Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from telethon import TelegramClient, events
- from config import tg_hash, tg_api, token
- server_id = 000000000000000
- channel_id = 00000000000000000
- chats = [-1000000000000, -1000000000000000]
- client = TelegramClient("Test", tg_api, tg_hash)
- async def send_message(message):
- intents = discord.Intents.default()
- intents.guilds = True
- intents.members = False
- intents.presences = False
- discord_client = discord.Client(intents=intents)
- @discord_client.event
- async def on_ready():
- print(f'{discord_client.user} is sanding new message')
- server = discord_client.get_guild(server_id)
- channel = server.get_channel(channel_id)
- await channel.send(message)
- await discord_client.close()
- await discord_client.start(token)
- print("Done")
- @client.on(events.NewMessage(chats=chats))
- async def handle_new_message(event):
- print("Got new message")
- if event.message.web_preview:
- print("Web_preview")
- elif event.message.photo:
- print("Photo")
- elif event.message.document:
- print("Document")
- elif event.message.text:
- print("Text")
- await send_message(event.message.message)
- client.start()
- client.run_until_disconnected()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement