txlyre há 1 mês atrás
pai
commit
6c3eda2976
2 ficheiros alterados com 12 adições e 2 exclusões
  1. 3 0
      config.yml.sample
  2. 9 2
      openkriemy.py

+ 3 - 0
config.yml.sample

@@ -13,3 +13,6 @@ MARKOV_CORPUS_SIZE: 10000
 MARKOV_STATE_SIZE: 3
 MARKOV_CHAIN_PATH: './markov_chain.json'
 MARKOV_CORPUS_PATH: './markov_corpus.json'
+MARKOV_TRIGGER_WORDS:
+    - 'bot'
+    - 'amogus'

+ 9 - 2
openkriemy.py

@@ -36,12 +36,19 @@ bot.markov = markov
 @bot.on(NewMessage)
 async def on_message(event):
     peer_id = get_peer_id(event.peer_id)
+    text = event.text
 
     try:
-        command = parse_command(event.text)
+        command = parse_command(text)
     except ValueError:
         if await is_markov_enabled(peer_id):
-            markov.extend_corpus(event.text)
+            markov.extend_corpus(text)
+
+            for word in config.MARKOV_TRIGGER_WORDS:
+              if word.lower() in text.lower() and random() > 0.5:
+                await markov_say(bot, peer_id, reply_to=event)
+
+                return
 
             reply_prob = await get_markov_option(peer_id, "opt_reply_prob")