-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
43 lines (31 loc) · 1.16 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
33
34
35
36
37
38
39
40
41
42
43
import time
import discord
import telegram_bot
import os
import parser
from dotenv import load_dotenv
load_dotenv()
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'We have logged in as {client.user}')
@client.event
async def on_message(message, game_url=None):
# if message.author == client.user:
# return
# send game recap
if 'gamerecap' in message.content:
msg = message.content
game_url=msg[msg.find('http'):]
parser.download_recap_img(game_url)
img_path = game_url[game_url.find("gamerecap"):] + '.png'
telegram_bot.send_img(img_path=img_path, chat_id=os.environ.get('TG_CHAT_ID'), token=os.environ.get('TG_TOKEN'), url=game_url)
await parser.del_recap_img(url=game_url)
if 'league' in message.content:
# print(type(message.content))
await telegram_bot.send_msg(msg=message.content, chat_id=os.environ.get('TG_CHAT_ID'), token=os.environ.get('TG_TOKEN'))
# await message.channel.send("JJJ")
if __name__ == '__main__':
client.run(token=os.environ.get('DISCORD_TOKEN'))