Esempio n. 1
0
func main() {
	rpcBind := os.Getenv("GOCHATBOT_RPC_BIND")
	if rpcBind == "" {
		log.Fatal("GOCHATBOT_RPC_BIND empty or not set. Cannot start plugin.")
	}
	r := &RedditPlugin{
		comm:       plugins.NewComm(rpcBind),
		subreddits: make(map[string][]string),
		recents:    make(map[string]map[string]string),
	}
	r.loadMemory()
	go r.watch()
	for {
		in, err := r.comm.Pop()
		if err != nil {
			log.Println("reddit: error popping message from gochatbot:", err)
			continue
		}
		if in.Message == "" {
			time.Sleep(1 * time.Second)
		}
		if err := r.parseMessage(in); err != nil {
			log.Println("reddit: error parsing message:", err)
		}
	}
}
Esempio n. 2
0
func main() {
	rpcBind := os.Getenv("GOCHATBOT_RPC_BIND")
	if rpcBind == "" {
		log.Fatal("GOCHATBOT_RPC_BIND empty or not set. Cannot start plugin.")
	}
	botName := os.Getenv("GOCHATBOT_NAME")
	if botName == "" {
		log.Fatal("GOCHATBOT_NAME empty or not set. Cannot start plugin.")
	}
	quiet, err := strconv.ParseBool(os.Getenv("GOCHATBOT_SENTIMENTAL_QUIET"))
	if err != nil {
		log.Println("error reading variable GOCHATBOT_SENTIMENTAL_QUIET, defaulting to false")
		quiet = false
	}

	r := &SentimentalPlugin{comm: plugins.NewComm(rpcBind), botName: botName, quiet: quiet}
	for {
		in, err := r.comm.Pop()
		if err != nil {
			log.Println("sentimental: error popping message from gochatbot:", err)
			continue
		}
		if in.Message == "" {
			time.Sleep(1 * time.Second)
		}
		if err := r.parseMessage(in); err != nil {
			log.Println("sentimental: error parsing message:", err)
		}
	}
}
Esempio n. 3
0
func main() {
	rpcBind := os.Getenv("GOCHATBOT_RPC_BIND")
	if rpcBind == "" {
		log.Fatal("GOCHATBOT_RPC_BIND empty or not set. Cannot start plugin.")
	}
	botName := os.Getenv("GOCHATBOT_NAME")
	if botName == "" {
		log.Fatal("GOCHATBOT_NAME empty or not set. Cannot start plugin.")
	}

	r := &GoAppReleasePlugin{comm: plugins.NewComm(rpcBind), botName: botName}
	for {
		in, err := r.comm.Pop()
		if err != nil {
			log.Println("goapp-release: error popping message from gochatbot:", err)
			continue
		}
		if in.Message == "" {
			time.Sleep(1 * time.Second)
		}
		if err := r.parseMessage(in); err != nil {
			log.Println("goapp-release: error parsing message:", err)
		}
	}
}
Esempio n. 4
0
func main() {
	rpcBind := os.Getenv("GOCHATBOT_RPC_BIND")
	if rpcBind == "" {
		log.Fatal("GOCHATBOT_RPC_BIND empty or not set. Cannot start plugin.")
	}
	botName := os.Getenv("GOCHATBOT_NAME")
	if botName == "" {
		log.Fatal("GOCHATBOT_NAME empty or not set. Cannot start plugin.")
	}

	r := &OpsPlugin{
		comm:    plugins.NewComm(rpcBind),
		botName: botName,

		cmds: allowedCmds,

		hostGroups:     make(map[string][]string),
		hostGroupsConf: make(map[string]sshConf),
	}

	log.Println("ops: reading from memory")
	memHG, err := r.comm.MemoryRead("ops", "hostGroups")
	if err != nil {
		log.Println("ops: error reading hostGroups from Bots memory")
	}
	if err := json.Unmarshal(memHG, &r.hostGroups); err == nil {
		log.Println("ops: hostGroups read")
	}

	memHGC, err := r.comm.MemoryRead("ops", "hostGroupsConf")
	if err != nil {
		log.Println("ops: error reading hostGroupsConf from Bots memory")
	}
	if err := json.Unmarshal(memHGC, &r.hostGroupsConf); err == nil {
		log.Println("ops: hostGroupsConf read")
	}

	for {
		in, err := r.comm.Pop()
		if err != nil {
			log.Println("ops: error popping message from gochatbot:", err)
			continue
		}
		if in.Message == "" {
			time.Sleep(1 * time.Second)
		}
		if err := r.parseMessage(in); err != nil {
			log.Println("ops: error parsing message:", err)
		}
	}
}
Esempio n. 5
0
func main() {
	rpcBind := os.Getenv("GOCHATBOT_RPC_BIND")
	if rpcBind == "" {
		log.Fatal("GOCHATBOT_RPC_BIND empty or not set. Cannot start plugin.")
	}
	botName := os.Getenv("GOCHATBOT_NAME")
	if botName == "" {
		log.Fatal("GOCHATBOT_NAME empty or not set. Cannot start plugin.")
	}

	trelloKey := os.Getenv("GOCHABOT_TRELLO_KEY")
	if trelloKey == "" {
		log.Fatal("GOCHABOT_TRELLO_KEY empty or not set. Cannot start plugin.")
	}
	trelloToken := os.Getenv("GOCHABOT_TRELLO_TOKEN")
	if trelloToken == "" {
		log.Fatal("GOCHABOT_TRELLO_TOKEN empty or not set. Cannot start plugin.")
	}
	trelloBoard := os.Getenv("GOCHABOT_TRELLO_BOARD")
	if trelloBoard == "" {
		log.Fatal("GOCHABOT_TRELLO_BOARD empty or not set. Cannot start plugin.")
	}

	tc, err := trello.NewAuthClient(trelloKey, &trelloToken)
	if err != nil {
		log.Fatal("could not connect to Trello")
	}

	r := &TrelloPlugin{
		comm:    plugins.NewComm(rpcBind),
		botName: botName,
		client:  tc,
		board:   trelloBoard,
	}
	for {
		in, err := r.comm.Pop()
		if err != nil {
			log.Println("trello error popping message from gochatbot:", err)
			continue
		}
		if in.Message == "" {
			time.Sleep(1 * time.Second)
		}
		if err := r.parseMessage(in); err != nil {
			log.Println("trello error parsing message:", err)
		}
	}
}