Update for ping role

This commit is contained in:
Daniel Mason 2020-03-21 15:00:53 +13:00
parent c6d668c65d
commit b5624db074
3 changed files with 6 additions and 2 deletions

View File

@ -2,3 +2,4 @@ DISCORD_TOKEN=""
DISCORD_CHANNELS="id1,id2,id3" DISCORD_CHANNELS="id1,id2,id3"
SOURCE_CHANNEL="" SOURCE_CHANNEL=""
REGEX_MATCH="^.*(K41|COVID).*$" REGEX_MATCH="^.*(K41|COVID).*$"
PING_ROLE=""

View File

@ -20,5 +20,5 @@ copy .env.example to .env and setup your user Token in .env
DISCORD_CHANNELS="channel_1_id,channel_2_id" DISCORD_CHANNELS="channel_1_id,channel_2_id"
SOURCE_CHANNEL="channel_id_to_listen_to" SOURCE_CHANNEL="channel_id_to_listen_to"
REGEX_MATCH="^.*(REGEX|TO|USE|TO|MATCH).*$" REGEX_MATCH="^.*(REGEX|TO|USE|TO|MATCH).*$"
PING_ROLE="id_of_role"

5
bot.py
View File

@ -15,7 +15,10 @@ class MyClient(discord.Client):
chan_list = [x.strip() for x in os.getenv("DISCORD_CHANNELS").split(',')] chan_list = [x.strip() for x in os.getenv("DISCORD_CHANNELS").split(',')]
for channel_id in chan_list: for channel_id in chan_list:
channel = client.get_channel(int(channel_id)) channel = client.get_channel(int(channel_id))
await channel.send('*' + message.content + '*') ping_string = ''
if os.getenv("PING_ROLE") != '':
ping_string = '<@&' + os.getenv("PING_ROLE") + '>: '
await channel.send(ping_string + message.content)
load_dotenv() load_dotenv()
client = MyClient() client = MyClient()