-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
59 lines (52 loc) · 2.04 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
import os
import re
from EdgeGPT import Chatbot, ConversationStyle
import interactions
TOKEN = "" # Тут токен твоего бота
COOKIE_PATH = 'cookie.json'
bot = interactions.Client(token=TOKEN)
EDGES = {}
my_conversation_style = ConversationStyle.balanced
guild_ids = [""] # Айдишка твоего сервера-канала
#Обязательно заюзай как только включил бота
@interactions.slash_command(
name="start",
description="Старт бота"
)
async def _start(ctx: interactions.SlashContext):
global EDGES
EDGES[ctx.author.id] = Chatbot(cookie_path=COOKIE_PATH)
await ctx.send(f"Ку, {ctx.author.name}! Юзай /help для большей информации.")
@interactions.slash_command(
name="help",
description="Показать список команд",
)
async def _help(ctx: interactions.SlashContext):
response = "Введи /help для инфы\nДля смены стиля, введи /switch и следуй: \ncreative (Creative)\nbalanced (Balanced)\nprecise (Strict)"
await ctx.send(response)
@interactions.slash_command(
name="switch",
description="Свитч стиля беседы",
)
async def _switch(ctx: interactions.SlashContext, style: str):
global my_conversation_style
styles = {
"creative": ConversationStyle.creative,
"balanced": ConversationStyle.balanced,
"precise": ConversationStyle.precise
}
my_conversation_style = styles[style]
await ctx.send(f"Current style: {style.capitalize()}")
@interactions.slash_command(
name="ask",
description="Задай мне вопрос",
)
async def _ask(ctx: interactions.SlashContext, question: str):
global EDGES
edge = EDGES.get(ctx.author.id)
if edge is None:
await ctx.send("Сначала ты должен запустить бота! Use /start")
return
response = edge.chat(question, my_conversation_style)
await ctx.send(response)
bot.start()