hardcoded version
This commit is contained in:
parent
ae2d398329
commit
297750f41f
1
.env
Normal file
1
.env
Normal file
@ -0,0 +1 @@
|
||||
DISCORD_TOKEN=MTI1NjU5NjQzNDc1MzQyNTQ3OQ.GCdylD.KsLG2fvwcPBe6seplQQUGUxoVl8T1iAhGvxmPg
|
50
main.py
Normal file
50
main.py
Normal file
@ -0,0 +1,50 @@
|
||||
from typing import Final
|
||||
import os
|
||||
|
||||
from discord.ext import commands
|
||||
from dotenv import load_dotenv
|
||||
from discord import Intents, Client, Message, User
|
||||
|
||||
|
||||
load_dotenv()
|
||||
TOKEN: Final[str] = os.getenv('DISCORD_TOKEN')
|
||||
|
||||
intents: Intents = Intents.none()
|
||||
intents.messages = True # NOQA
|
||||
intents.message_content = True # NOQA
|
||||
client: Client = Client(intents=intents)
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_ready() -> None:
|
||||
print('Sentinel ready !')
|
||||
|
||||
@client.event
|
||||
async def on_message(message: Message) -> None:
|
||||
|
||||
user_message: str = str(message.content)
|
||||
|
||||
if message.author == client.user:
|
||||
# to avoid infinite loop, let's not answer to messages we (client.user) emit ourselves
|
||||
print('no answer to our own message')
|
||||
return
|
||||
if not user_message:
|
||||
print('no message to send')
|
||||
return
|
||||
if message.channel.id != 1218161058599141386:
|
||||
print('channel not monitored')
|
||||
if 'Kriss' not in user_message:
|
||||
print('message not implying "Kriss"')
|
||||
|
||||
print(f'[{str(message.channel)}] {str(message.author)}: "{user_message}"')
|
||||
|
||||
try:
|
||||
await client.get_channel(1256995195954790410).send(user_message)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def main() -> None:
|
||||
client.run(token=TOKEN)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
discord
|
||||
python-dotenv
|
Loading…
Reference in New Issue
Block a user