Skip to content

Commit

Permalink
update cfg file
Browse files Browse the repository at this point in the history
  • Loading branch information
SuInk committed Feb 15, 2023
1 parent a5a0a98 commit d33bdd8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
config.toml
config.cfg
main.exe
.idea
main
2 changes: 1 addition & 1 deletion cmd/cqhttp/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (bot *Bot) HandleMsg(rawData []byte) {
log.Println(err)
}
// 准备处理消息
isAt, err := regexp.MatchString(`[CQ:at,qq=`+string(rcvMsg.SelfId)+`]`, rcvMsg.RawMessage)
isAt, err := regexp.MatchString(`CQ:at,qq=`+strconv.FormatInt(rcvMsg.SelfId, 10), rcvMsg.RawMessage)
if err != nil {
log.Println(err)
}
Expand Down
2 changes: 1 addition & 1 deletion config.example.toml → config.example.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# config.toml 配置文件
# config.cfg 配置文件

# cqhttp机器人配置
[cqhttp]
Expand Down
8 changes: 4 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ var Cfg Config

func init() {
log.SetFlags(log.Lshortfile | log.LstdFlags)
if _, err := os.Stat("config.toml"); os.IsNotExist(err) {
f, err := os.Create("config.toml")
if _, err := os.Stat("config.cfg"); os.IsNotExist(err) {
f, err := os.Create("config.cfg")
if err != nil {
log.Println(err)
}
_, err = f.Write([]byte("# config.toml 配置文件\n\n# cqhttp机器人配置\n[cqhttp]\n# go-cqhttp的正向WebSocket地址\nwebsocket = \"ws://127.0.0.1:8080\"\n# 是否需要@机器人才能触发\nat_only = true\n# 生成中提醒时间秒数\ntimeout = 30\n\n# openai配置\n[openai]\n# 你的 OpenAI API Key, 可以在 https://beta.openai.com/account/api-keys 获取\napi_key = \"sk-xxxxx\"\n# 使用的模型,默认是 text-davinci-003\nmodel = \"text-davinci-003\"\n# 对话温度,越大越随机 参照https://algowriting.medium.com/gpt-3-temperature-setting-101-41200ff0d0be\ntemperature = 0.3\n# 每次对话最大生成字符数\nmax_tokens = 1000\n\n"))
_, err = f.Write([]byte("# config.cfg 配置文件\n\n# cqhttp机器人配置\n[cqhttp]\n# go-cqhttp的正向WebSocket地址\nwebsocket = \"ws://127.0.0.1:8080\"\n# 是否需要@机器人才能触发\nat_only = true\n# 生成中提醒时间秒数\ntimeout = 30\n\n# openai配置\n[openai]\n# 你的 OpenAI API Key, 可以在 https://beta.openai.com/account/api-keys 获取\napi_key = \"sk-xxxxx\"\n# 使用的模型,默认是 text-davinci-003\nmodel = \"text-davinci-003\"\n# 对话温度,越大越随机 参照https://algowriting.medium.com/gpt-3-temperature-setting-101-41200ff0d0be\ntemperature = 0.3\n# 每次对话最大生成字符数\nmax_tokens = 1000\n\n"))
if err != nil {
log.Println(err)
}
log.Println("配置文件不存在, 已自动生成配置文件, 请修改配置文件后再次运行程序, 5秒后退出程序...")
time.Sleep(5 * time.Second)
os.Exit(0)
}
viper.SetConfigName("config")
viper.SetConfigName("config.cfg")
viper.SetConfigType("toml")
viper.AddConfigPath(".") // 指定查找配置文件的路径
err := viper.ReadInConfig()
Expand Down

0 comments on commit d33bdd8

Please sign in to comment.