mirror of
https://github.com/idanoo/discord-keyword-bot.git
synced 2024-11-23 08:55:13 +00:00
Initial Commit
This commit is contained in:
commit
a480c2c898
4
.env.example
Normal file
4
.env.example
Normal file
@ -0,0 +1,4 @@
|
||||
DISCORD_TOKEN=""
|
||||
DISCORD_CHANNELS="id1,id2,id3"
|
||||
SOURCE_CHANNEL=""
|
||||
REGEX_MATCH="^.*(K41|COVID).*$"
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.env
|
13
README.md
Normal file
13
README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Python Discord Keyword Bot
|
||||
|
||||
### Requirements
|
||||
python3 / pip3
|
||||
|
||||
### Install
|
||||
copy .env.example to .env and setup your user Token in .env
|
||||
|
||||
|
||||
pip3 install -r requirements.txt
|
||||
python3 boy.py
|
||||
|
||||
|
21
bot.py
Normal file
21
bot.py
Normal file
@ -0,0 +1,21 @@
|
||||
import discord
|
||||
import os
|
||||
import re
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# https://discordpy.readthedocs.io/en/latest/api.html
|
||||
|
||||
class MyClient(discord.Client):
|
||||
async def on_ready(self):
|
||||
print('Logged on as', self.user)
|
||||
|
||||
async def on_message(self, message):
|
||||
if message.channel.id == os.getenv("SOURCE_CHANNEL"):
|
||||
if re.match(os.getenv("REGEX_MATCH"), message.content, re.IGNORECASE):
|
||||
for channel_id in explode(os.getenv("DISCORD_CHANNELS")):
|
||||
channel = client.get_channel(channel_id)
|
||||
await channel.send('*' + message.content + '*')
|
||||
|
||||
load_dotenv()
|
||||
client = MyClient()
|
||||
client.run(os.getenv("DISCORD_TOKEN"), bot=False)
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
python-dotenv
|
||||
discord.py
|
Loading…
Reference in New Issue
Block a user