This commit is contained in:
shoopea 2019-05-03 12:39:16 +08:00
parent d984dc4f7f
commit 47b9e78d7d
2 changed files with 32 additions and 4 deletions

5
gocw2.sample.cfg Normal file
View File

@ -0,0 +1,5 @@
[rabbit]
user = guest
password = guest
host = localhost:5672
queue = chatwars

31
main.go
View File

@ -26,11 +26,34 @@ type ChatWarsMessage struct {
const user_chtwrsbot = 408101137
var ownUserID64 = int64(0)
var ownUserID32 = int32(0)
type Config struct {
Rabbit struct {
User string
Password string
Host string
Queue string
}
}
var (
config = flag.String("config", "gocw2.cfg", "config file path")
initdb = flag.Bool("initdb", false, "initialize tracker database")
cfg Config
ownUserID64 = int64(0)
ownUserID32 = int32(0)
)
func main() {
// msgMutex = &sync.Mutex{}
// Parsing config
flag.Parse()
err = gcfg.ReadFileInto(&cfg, *config)
if err != nil {
log.Fatalf("Failed to parse gcfg data: %s", err)
}
tdlib.SetLogVerbosityLevel(1)
tdlib.SetFilePath("./errors.txt")
@ -107,7 +130,7 @@ func ListenCW(c *tdlib.Client) {
return false
}
conn, err := amqp.Dial("amqp://shoopea:UmDd5g4WRa2MzqOHsG2T@localhost:5672/chatwars")
conn, err := amqp.Dial("amqp://" + cfg.Rabbit.User + ":" + cfg.Rabbit.Password + "@" + cfg.Rabbit.Host + "/" + cfg.Rabbit.Queue)
if err != nil {
log.Fatal(err)
}