-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.py
69 lines (58 loc) · 1.98 KB
/
constants.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
63
64
65
66
67
68
69
from dotenv import load_dotenv
import os
import dacite
import yaml
from typing import Dict, List
from base import Config
load_dotenv()
# load config.yaml
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
CONFIG: Config = dacite.from_dict(
Config, yaml.safe_load(open(os.path.join(SCRIPT_DIR, "config.yaml"), "r"))
)
BOT_NAME = CONFIG.name
BOT_INSTRUCTIONS = CONFIG.instructions
EXAMPLE_CONVOS = CONFIG.example_conversations
DISCORD_BOT_TOKEN = os.environ["DISCORD_BOT_TOKEN"]
DISCORD_CLIENT_ID = os.environ["DISCORD_CLIENT_ID"]
OPENAI_API_KEY = os.environ["OPENAI_API_KEY"]
ALLOWED_SERVER_IDS: List[int] = []
server_ids = os.environ["ALLOWED_SERVER_IDS"].split(",")
for s in server_ids:
ALLOWED_SERVER_IDS.append(int(s))
SERVER_TO_MODERATION_CHANNEL: Dict[int, int] = {}
server_channels = os.environ.get("SERVER_TO_MODERATION_CHANNEL", "").split(",")
for s in server_channels:
values = s.split(":")
SERVER_TO_MODERATION_CHANNEL[int(values[0])] = int(values[1])
private_thread='362924812288'
public_thread='328565073920'
# Send Messages, Create Public Threads, Send Messages in Threads, Manage Messages, Manage Threads, Read Message History, Use Slash Command
BOT_INVITE_URL = f"https://discord.com/api/oauth2/authorize?client_id={DISCORD_CLIENT_ID}&permissions={private_thread}&scope=bot"
MODERATION_VALUES_FOR_BLOCKED = {
"hate": 0.5,
"hate/threatening": 0.1,
"self-harm": 0.2,
"sexual": 0.5,
"sexual/minors": 0.2,
"violence": 0.7,
"violence/graphic": 0.8,
}
MODERATION_VALUES_FOR_FLAGGED = {
"hate": 0.4,
"hate/threatening": 0.05,
"self-harm": 0.1,
"sexual": 0.3,
"sexual/minors": 0.1,
"violence": 0.1,
"violence/graphic": 0.1,
}
SECONDS_DELAY_RECEIVING_MSG = (
3 # give a delay for the bot to respond so it can catch multiple messages
)
MAX_THREAD_MESSAGES = 200
ACTIVATE_THREAD_PREFX = "💬✅"
INACTIVATE_THREAD_PREFIX = "💬❌"
MAX_CHARS_PER_REPLY_MSG = (
1500 # discord has a 2k limit, we just break message into 1.5k
)