forked from voidbar/forwardgram
-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathdiscord_messager.py
61 lines (45 loc) · 1.81 KB
/
discord_messager.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import yaml
import sys
import logging
import discord
'''
------------------------------------------------------------------------
DISCORD CLIENT - Init the client
------------------------------------------------------------------------
'''
discord_client = discord.Client()
with open('config.yml', 'rb') as f:
config = yaml.safe_load(f)
'''
------------------------------------------------------------------------
MESSAGE AS WE RECIEVE FROM FORWARDGRAM SCRIPT
------------------------------------------------------------------------
'''
message = sys.argv[1]
'''
------------------------------------------------------------------------
DISCORD SERVER START EVENT - We will kill this immaturely
------------------------------------------------------------------------
'''
# when discord is initalized, it will trigger this event.
# we quickly send messages to our discord channels and quit the script prematurely.
# this gets trigged again when a new message is sent on channel from telegram
@discord_client.event
async def on_ready():
print('We have logged in as {0.user}'.format(discord_client))
print('Awaiting Telegram Message')
# My channels are for RTX card drops and PS5
channel_1 = discord_client.get_channel(config["discord_1_channel"])
channel_2 = discord_client.get_channel(config["discord_2_channel"])
channel_3 = discord_client.get_channel(config["discord_3_channel"])
channel_4 = discord_client.get_channel(config["discord_4_channel"])
if 'Mario' in message:
await channel_1.send(message)
elif 'Zelda' in message:
await channel_2.send(message)
elif 'Minecraft' in message:
await channel_3.send(message)
elif 'Valhiem' in message:
await channel_4.send(message)
quit()
discord_client.run(config["discord_bot_token"])