-
Notifications
You must be signed in to change notification settings - Fork 1
/
onebot.go
68 lines (50 loc) · 1.46 KB
/
onebot.go
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
// Copyright (c) 2020-2022, The OneBot Contributors. All rights reserved.
package main
/* CONFIG SPEC
Config values should use those set in config file until overriden via database entry (IE: value changed via command in
chat).
Configuration file will be in TOML, whatever version is most convenient.
*/
/* TODO
- DBs (LevelDB(x) / MongoDB)
- Plugin system
- Setup default plugin folder
- Protocol system
- Setup default protocol folder
(x) == completed
*/
import (
. "github.com/TheDiscordian/onebot/onelib"
"os"
"os/signal"
"syscall"
)
const (
// NAME is the default display name of the bot
NAME = "OneBot"
)
/* DATABASE SPEC
DBs should perhaps support conversion to other DBs for portability.
Plugins may not include a "." or "~" in key names.
LevelDB indexes will be stored as "tableName.indexKey.indexValue", the value contains the key to get the value
LevelDB values will be stored as "tableName.key", key will be the ID of the object
LevelDB keys will be generated as regular MongoDB ObjectIDs in bytes, unless explicitly specified
*/
func main() {
InitLoggers("onebot.log")
Info.Printf("Starting up %s %s...\n", NAME, VERSION)
LoadConfig()
Info.Println("Loading protocols...")
LoadProtocols()
Info.Println("Loading plugins...")
LoadPlugins()
Info.Println("Plugins initialized!")
defer func() {
Info.Println("Shutting down...")
UnloadPlugins()
UnloadProtocols()
Db.Close()
}()
signal.Notify(Quit, os.Interrupt, syscall.SIGTERM)
<-Quit
}