mirror of
https://github.com/idanoo/discord-keyword-bot.git
synced 2024-11-22 00:21:52 +00:00
Changes
This commit is contained in:
parent
b5624db074
commit
2fd99c369c
@ -1,5 +1,4 @@
|
|||||||
DISCORD_TOKEN=""
|
DISCORD_TOKEN=""
|
||||||
DISCORD_CHANNELS="id1,id2,id3"
|
DISCORD_CHANNEL=""
|
||||||
SOURCE_CHANNEL=""
|
SOURCE_CHANNEL=""
|
||||||
REGEX_MATCH="^.*(K41|COVID).*$"
|
REGEX_MATCH="^.*(K41|COVID).*$"
|
||||||
PING_ROLE=""
|
|
||||||
|
@ -17,8 +17,7 @@ copy .env.example to .env and setup your user Token in .env
|
|||||||
.env file layout
|
.env file layout
|
||||||
|
|
||||||
DISCORD_TOKEN="token_from_web"
|
DISCORD_TOKEN="token_from_web"
|
||||||
DISCORD_CHANNELS="channel_1_id,channel_2_id"
|
DISCORD_CHANNELS="channel_1_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"
|
|
||||||
|
|
||||||
|
9
bot.py
9
bot.py
@ -12,13 +12,8 @@ class MyClient(discord.Client):
|
|||||||
async def on_message(self, message):
|
async def on_message(self, message):
|
||||||
if message.channel.id == int(os.getenv("SOURCE_CHANNEL")):
|
if message.channel.id == int(os.getenv("SOURCE_CHANNEL")):
|
||||||
if re.match(os.getenv("REGEX_MATCH"), message.content, re.IGNORECASE):
|
if re.match(os.getenv("REGEX_MATCH"), message.content, re.IGNORECASE):
|
||||||
chan_list = [x.strip() for x in os.getenv("DISCORD_CHANNELS").split(',')]
|
channel = client.get_channel(int(os.getenv("DISCORD_CHANNEL"))
|
||||||
for channel_id in chan_list:
|
await channel.send(message.content)
|
||||||
channel = client.get_channel(int(channel_id))
|
|
||||||
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()
|
||||||
|
Loading…
Reference in New Issue
Block a user