mirror of
https://github.com/idanoo/discord-keyword-bot.git
synced 2024-11-21 08:01:53 +00:00
Re-add multi-channel support
This commit is contained in:
parent
05e10e852a
commit
1144a4cb2f
@ -1,4 +1,4 @@
|
||||
DISCORD_TOKEN=""
|
||||
DISCORD_CHANNEL=""
|
||||
DISCORD_CHANNELS=""
|
||||
SOURCE_CHANNEL=""
|
||||
REGEX_MATCH="^.*(K41|COVID).*$"
|
||||
|
@ -17,7 +17,7 @@ copy .env.example to .env and setup your user Token in .env
|
||||
.env file layout
|
||||
|
||||
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"
|
||||
REGEX_MATCH="^.*(REGEX|TO|USE|TO|MATCH).*$"
|
||||
|
||||
|
6
bot.py
6
bot.py
@ -12,8 +12,10 @@ class MyClient(discord.Client):
|
||||
async def on_message(self, message):
|
||||
if message.channel.id == int(os.getenv("SOURCE_CHANNEL")):
|
||||
if re.match(os.getenv("REGEX_MATCH"), message.content, re.IGNORECASE):
|
||||
channel = client.get_channel(int(os.getenv("DISCORD_CHANNEL")))
|
||||
await channel.send(message.content)
|
||||
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)
|
||||
|
||||
load_dotenv()
|
||||
client = MyClient()
|
||||
|
Loading…
Reference in New Issue
Block a user