mirror of
https://github.com/idanoo/discord-keyword-bot.git
synced 2024-11-24 17:35:13 +00:00
Re-add multi-channel support
This commit is contained in:
parent
05e10e852a
commit
1144a4cb2f
@ -1,4 +1,4 @@
|
|||||||
DISCORD_TOKEN=""
|
DISCORD_TOKEN=""
|
||||||
DISCORD_CHANNEL=""
|
DISCORD_CHANNELS=""
|
||||||
SOURCE_CHANNEL=""
|
SOURCE_CHANNEL=""
|
||||||
REGEX_MATCH="^.*(K41|COVID).*$"
|
REGEX_MATCH="^.*(K41|COVID).*$"
|
||||||
|
@ -17,7 +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"
|
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).*$"
|
||||||
|
|
||||||
|
4
bot.py
4
bot.py
@ -12,7 +12,9 @@ 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):
|
||||||
channel = client.get_channel(int(os.getenv("DISCORD_CHANNEL")))
|
chan_list = [x.strip() for x in os.getenv("DISCORD_CHANNELS").split(',')]
|
||||||
|
for channel_id in chan_list:
|
||||||
|
channel = client.get_channel(int(channel_id))
|
||||||
await channel.send(message.content)
|
await channel.send(message.content)
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
Loading…
Reference in New Issue
Block a user