mirror of
https://github.com/AskDavis/nate-discord.git
synced 2026-01-01 05:05:58 -08:00
fix async blocking issue
This commit is contained in:
@@ -13,7 +13,7 @@ ADD . .
|
|||||||
# Install any needed packages specified in requirements.txt
|
# Install any needed packages specified in requirements.txt
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
# Make port 80 available to the world outside this container
|
# Make port 8080 available to the world outside this container
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
# Run run.py when the container launches
|
# Run run.py when the container launches
|
||||||
|
|||||||
@@ -10,14 +10,15 @@ class MyClient(discord.Client):
|
|||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print('Logged in as: ', self.user)
|
print('Logged in as: ', self.user)
|
||||||
async def on_message(self, message):
|
async def on_message(self, message):
|
||||||
if message.author == self.user:
|
if message.author == client.user:
|
||||||
return
|
return
|
||||||
message_content=message.content
|
if message.content.startswith('!mabel'):
|
||||||
chat_response=chatgpt_response(message_content)
|
prompt = message.content[7:]
|
||||||
if "mabel" in message_content.lower() or "Mabel" in message_content.lower():
|
response = await chatgpt_response(prompt)
|
||||||
print(message_content)
|
await message.channel.send(response)
|
||||||
await message.channel.send(f"{chat_response}")
|
|
||||||
return
|
|
||||||
intents=discord.Intents.default()
|
intents=discord.Intents.default()
|
||||||
intents.messages=True
|
intents.messages=True
|
||||||
client=MyClient(intents=intents)
|
client=MyClient(intents=intents)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ def load_system_directives():
|
|||||||
system_directives = json.load(f)
|
system_directives = json.load(f)
|
||||||
return system_directives
|
return system_directives
|
||||||
|
|
||||||
def chatgpt_response(prompt):
|
async def chatgpt_response(prompt):
|
||||||
global DIALOGUE_STACK, SYSTEM_DIRECTIVES
|
global DIALOGUE_STACK, SYSTEM_DIRECTIVES
|
||||||
SYSTEM_DIRECTIVES = load_system_directives()
|
SYSTEM_DIRECTIVES = load_system_directives()
|
||||||
current_prompt = {"role": "user", "content": prompt}
|
current_prompt = {"role": "user", "content": prompt}
|
||||||
|
|||||||
1
run.py
1
run.py
@@ -2,4 +2,5 @@ from app.discord_bot.connect_discord import client, discord_token
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print("Starting Discord Bot")
|
print("Starting Discord Bot")
|
||||||
|
# run the discord bot on port 8080
|
||||||
client.run(discord_token)
|
client.run(discord_token)
|
||||||
Reference in New Issue
Block a user