upd
This commit is contained in:
parent
d984dc4f7f
commit
47b9e78d7d
5
gocw2.sample.cfg
Normal file
5
gocw2.sample.cfg
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[rabbit]
|
||||||
|
user = guest
|
||||||
|
password = guest
|
||||||
|
host = localhost:5672
|
||||||
|
queue = chatwars
|
31
main.go
31
main.go
@ -26,11 +26,34 @@ type ChatWarsMessage struct {
|
|||||||
|
|
||||||
const user_chtwrsbot = 408101137
|
const user_chtwrsbot = 408101137
|
||||||
|
|
||||||
var ownUserID64 = int64(0)
|
type Config struct {
|
||||||
var ownUserID32 = int32(0)
|
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() {
|
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.SetLogVerbosityLevel(1)
|
||||||
tdlib.SetFilePath("./errors.txt")
|
tdlib.SetFilePath("./errors.txt")
|
||||||
|
|
||||||
@ -107,7 +130,7 @@ func ListenCW(c *tdlib.Client) {
|
|||||||
return false
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user