-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
30 lines (25 loc) · 767 Bytes
/
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
from telegram import Bot, Update
from keys import *
import discord
dc = discord.Client()
tg = Bot(token=TELEGRAM_TOKEN)
@dc.event
async def on_message(message):
try:
serverName = message.guild.name
channelName = message.channel.name
except AttributeError:
pass
if message.channel.id in DISCORD_CHANNELS:
toSend = f"{message.guild}/{message.channel}/{message.author.name}: {message.content}"
print(toSend)
tg.sendMessage(chat_id=TELEGRAM_CHAT_ID, text=toSend)
def main():
try:
print("Running, waiting for messages...")
dc.run(DISCORD_TOKEN)
except errors.HTTPException:
print("Invalid discord token or network down!")
quit()
if __name__ == '__main__':
main()