-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
62 lines (43 loc) · 1.93 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import discord
import os
from dotenv import load_dotenv
from jiraiya.create_chat.create_chat import create_chat
from jiraiya.quiz import send_quiz
from jiraiya.scroll import send_scroll
from jiraiya.send_messages import send_message, send_gpt_message, send_random_emoji
def run_discord_bot():
load_dotenv(".env")
TOKEN = os.getenv("DISCORD_TOKEN")
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'{client.user} is now running!')
@client.event
async def on_message(message):
if message.author == client.user:
return
user_message = str(message.content)
if user_message.startswith('/'):
await create_chat(message, user_message)
elif user_message.startswith('!') or user_message.startswith('?'):
is_private = False if user_message.startswith('!') else True
if "quiz" in user_message:
await send_quiz(message, user_message, is_private)
elif "scroll" in user_message:
await send_scroll(message, user_message, is_private)
else:
await send_message(message, user_message, is_private)
elif any(x in user_message for x in ["Jiraiya","jiraiya","Jiraia","jiraia","ჯირაია","ჯერაია"]):
if any(x in user_message for x in ["ჯერაია","ჯირაია"]):
await send_gpt_message(message, user_message, message_lang="ka")
elif any(x in user_message for x in ["jiraia","Jiraia"]):
await send_gpt_message(message, user_message, message_lang="ka", is_latin_ka=True)
else:
await send_gpt_message(message, user_message)
else:
await send_random_emoji(message)
client.run(TOKEN)
if __name__ == '__main__':
run_discord_bot()