Exemple #1
0
func handleMessages(messages chan telebot.Message, bot *telebot.Bot, fixrAccessor *fixrdb.FixrDB, done chan bool) {

	// range over the channel of messages, handle the message sent, log any error.
	for message := range messages {
		logging.Info(fmt.Sprintf("Got message \"%s\" from %v", message.Text, message.Chat))
		err := fixrtelegram.HandleAction(message, bot, fixrAccessor)
		if err != nil {
			logging.Error(err)
		}
	}

	// we're done, notify other goroutine
	done <- true
}
Exemple #2
0
// Send a Fixer message to all registered users.
func SendAll(bot *telebot.Bot, fa *fixrdb.FixrDB) error {
	members, err := fa.GetRegistered()
	if err != nil {
		return err
	}
	for _, member := range members {
		var err error
		user, _ := strconv.Atoi(member)
		err = sendTo(user, bot, fa)
		if err != nil {
			logging.Error(err)
		}
	}
	return nil
}