public.go 652 B

12345678910111213141516171819202122232425262728293031323334
  1. package public
  2. import (
  3. "strings"
  4. "github.com/eryajf/chatgpt-dingtalk/config"
  5. "github.com/eryajf/chatgpt-dingtalk/pkg/cache"
  6. )
  7. var UserService cache.UserServiceInterface
  8. var Config *config.Configuration
  9. var Prompt *[]config.Prompt
  10. func InitSvc() {
  11. Config = config.LoadConfig()
  12. Prompt = config.LoadPrompt()
  13. UserService = cache.NewUserService()
  14. _, _ = GetBalance()
  15. }
  16. func FirstCheck(rmsg ReceiveMsg) bool {
  17. lc := UserService.GetUserMode(rmsg.SenderStaffId)
  18. if lc == "" {
  19. if Config.DefaultMode == "串聊" {
  20. return true
  21. } else {
  22. return false
  23. }
  24. }
  25. if lc != "" && strings.Contains(lc, "串聊") {
  26. return true
  27. }
  28. return false
  29. }