Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
fix wordCloud功能 词云
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoo committed Jul 25, 2021
1 parent c320a43 commit cc8255d
Show file tree
Hide file tree
Showing 7 changed files with 582 additions and 520 deletions.
9 changes: 9 additions & 0 deletions BanWord/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ func Hook(b *Core.Bot) error {
} else {
c = Config.CoreConfig.DefaultGroupConfig
}
banQQ := Config.CoreConfig.BanQQ
Config.Lock.RUnlock()

for _, v := range banQQ {
if packet.FromUserID == v {
packet.Ban = true
return
}
}

if !c.Enable {
return
}
Expand Down
76 changes: 38 additions & 38 deletions Config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"
"sync"

"github.com/fsnotify/fsnotify"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -36,6 +35,7 @@ type CoreConfigStruct struct {
PixivRefreshToken string
PixivProxy string
}
BanQQ []int64
Debug bool
BiliLive bool
YiQing bool
Expand Down Expand Up @@ -113,10 +113,10 @@ func Save() error {
}

func init() {
watcher, err := fsnotify.NewWatcher()
if err != nil {
log.Fatal(err)
}
//watcher, err := fsnotify.NewWatcher()
//if err != nil {
// log.Fatal(err)
//}

if len(os.Args) == 2 && os.Args[1] == "first" {
b, err := yaml.Marshal(CoreConfig)
Expand All @@ -140,38 +140,38 @@ func init() {
panic(err)
}
Save()
go func() {
for {
select {
case event, ok := <-watcher.Events:
if !ok {
return
}
if event.Op&fsnotify.Write == fsnotify.Write {
b, err := ioutil.ReadFile("./config.yaml")
if err != nil {
log.Println("读取配置文件失败")
break
}
Lock.Lock()
err = yaml.Unmarshal(b, &CoreConfig)
Lock.Unlock()
if err != nil {
log.Println("读取配置文件失败")
break
}
}
case err, ok := <-watcher.Errors:
if !ok {
return
}
log.Println("error:", err)
}
}
}()
err = watcher.Add("./config.yaml")
if err != nil {
log.Fatal(err)
}
//go func() {
// for {
// select {
// case event, ok := <-watcher.Events:
// if !ok {
// return
// }
// if event.Op&fsnotify.Write == fsnotify.Write {
// b, err := ioutil.ReadFile("./config.yaml")
// if err != nil {
// log.Println("读取配置文件失败")
// break
// }
// Lock.Lock()
// err = yaml.Unmarshal(b, &CoreConfig)
// Lock.Unlock()
// if err != nil {
// log.Println("读取配置文件失败")
// break
// }
// }
// case err, ok := <-watcher.Errors:
// if !ok {
// return
// }
// log.Println("error:", err)
// }
// }
//}()
//err = watcher.Add("./config.yaml")
//if err != nil {
// log.Fatal(err)
//}
dbInit()
}
Loading

0 comments on commit cc8255d

Please sign in to comment.