forked from an/flokati
		
	markov.go: !talk
This commit is contained in:
		
							parent
							
								
									59bf94f173
								
							
						
					
					
						commit
						76a383cf0c
					
				
					 1 changed files with 19 additions and 0 deletions
				
			
		| 
						 | 
					@ -39,6 +39,25 @@ func init() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func markovHandleMessage(m *Message) {
 | 
					func markovHandleMessage(m *Message) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						tok := strings.Split(m.Text, " ")
 | 
				
			||||||
 | 
						if tok[0] == "!talk" {
 | 
				
			||||||
 | 
							if len(tok) < 2 {
 | 
				
			||||||
 | 
								SayCh <- m.Channel + "\npfffrrz ... worüber denn?"
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								talk := tok[1]
 | 
				
			||||||
 | 
								for {
 | 
				
			||||||
 | 
									time.Sleep(time.Duration(rand.Intn(8)+2 * time.Second)
 | 
				
			||||||
 | 
									talk = markovChain.Generate(*markovAnswerLen, talk)
 | 
				
			||||||
 | 
									SayCh <- m.Channel + "\n" + talk
 | 
				
			||||||
 | 
									if rand.Intn(100) < 10 {
 | 
				
			||||||
 | 
										break
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	text := m.Text
 | 
						text := m.Text
 | 
				
			||||||
	if text == "" {
 | 
						if text == "" {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue