// loop returns true if need to run again, otherwise false.
loop returns true if need to run again, otherwise false.
// loop returns true if need to run again otherwise false .
func (b *Bot) loop() bool {
	for {
		select {
		case <-b.closeCh:
			return false
		case e, ok := <-b.inputCh:
			if !ok {
				return true
			}
			log.Tracef("got event: %v", e)
			switch e := e.(type) {
			case *events.ChatJoinEvent:
			case *events.MessageEvent:
				cmd, err := command.ParseCommand(e.Message)
				if err != nil {
					continue
				}
				answer, err := cmd.Answer()
				if err != nil {
					continue
				}
				if err := b.messageDB.Post(models.NewMessage("Bot", answer, e.ChatName)); err != nil {
					log.Errorf("bot: couldn't post message: %v", err)
				}
			default:
			}
		}
	}
}
func ( b * Bot ) loop ( ) bool { for { select { case <- b . closeCh : return false case e , ok := <- b . inputCh : if ! ok { return true } log . Tracef ( " " , e ) switch e := e . ( type ) { case * events . ChatJoinEvent : case * events . MessageEvent : cmd , err := command . ParseCommand ( e . Message ) if err != nil { continue } answer , err := cmd . Answer ( ) if err != nil { continue } if err := b . messageDB . Post ( models . NewMessage ( " " , answer , e . ChatName ) ) ; err != nil { log . Errorf ( " " , err ) } default : } } } }
loop returns true if need to run again, otherwise false.
loop returns true if need to run again otherwise false .
// channel has been closed, go reconnect // maybe greet user