All Projects → smashwilson → hubot-markov

smashwilson / hubot-markov

Licence: MIT license
Hubot watches all, and builds a markov model from everything you say.

Programming Languages

coffeescript
4710 projects

Projects that are alternatives of or similar to hubot-markov

Hubot Slack
Slack Developer Kit for Hubot
Stars: ✭ 2,260 (+3487.3%)
Mutual labels:  hubot
hubot-seen
A hubot script that tracks when/where users were last seen.
Stars: ✭ 25 (-60.32%)
Mutual labels:  hubot
hubot-alias
Action alias for hubot
Stars: ✭ 21 (-66.67%)
Mutual labels:  hubot
ansible-hubot
💬 Ansible role for Hubot
Stars: ✭ 63 (+0%)
Mutual labels:  hubot
gubot
A hubot like bot written in golang which is langage agnostic and cloud agnostic
Stars: ✭ 29 (-53.97%)
Mutual labels:  hubot
DISCOTRESS
🦜 DISCOTRESS 🦜 is a software package to simulate and analyse the dynamics on arbitrary Markov chains
Stars: ✭ 20 (-68.25%)
Mutual labels:  markov-model
Pull Review
✅ Assign pull request reviewers intelligently.
Stars: ✭ 179 (+184.13%)
Mutual labels:  hubot
hubot-pager-me
PagerDuty integration for Hubot
Stars: ✭ 74 (+17.46%)
Mutual labels:  hubot
evolution
proposals for changes and user-visible enhancements to Hubot
Stars: ✭ 42 (-33.33%)
Mutual labels:  hubot
mattermost-client
Mattermost client using websockets
Stars: ✭ 59 (-6.35%)
Mutual labels:  hubot
hubot-github-repo-event-notifier
Notifies about any GitHub repo event available via webhook.
Stars: ✭ 58 (-7.94%)
Mutual labels:  hubot
hubot-schedule
A hubot script to schedule a message in both cron-style and datetime-based format pattern
Stars: ✭ 46 (-26.98%)
Mutual labels:  hubot
hubot-bearychat
BearyChat Adapter for Hubot
Stars: ✭ 99 (+57.14%)
Mutual labels:  hubot
Sactive Bot
😈 An extensible chat bot framework. sactive-bot is an evolution of the open source hubot project. - https://www.shipengqi.top/sactive-bot .
Stars: ✭ 212 (+236.51%)
Mutual labels:  hubot
mchmm
Markov Chains and Hidden Markov Models in Python
Stars: ✭ 89 (+41.27%)
Mutual labels:  markov-model
Hubot Xmpp
XMPP adapter for Hubot
Stars: ✭ 185 (+193.65%)
Mutual labels:  hubot
Huggies
Huggies is a plug and play automation tool for AWS Elastic Beanstalk
Stars: ✭ 13 (-79.37%)
Mutual labels:  hubot
hackmit-hackbot
🤖 HackMIT's personal assistant!
Stars: ✭ 13 (-79.37%)
Mutual labels:  hubot
m3gm
Max-Margin Markov Graph Models for WordNet (EMNLP 2018)
Stars: ✭ 40 (-36.51%)
Mutual labels:  markov-model
hubot-broadlink-rm
A hubot script to learn and send IR hex codes with Broadlink RM
Stars: ✭ 24 (-61.9%)
Mutual labels:  hubot

Hubot Markov Model

npm | Continuous Integration

Generates a markov model based on everything that your Hubot sees in your chat.

Installing

  1. Add hubot-markov to your package.json with npm install --save hubot-markov:
  "dependencies": {
    "hubot-markov": "~2.0.0"
  },
  1. Require the module in external-scripts.json:
["hubot-markov"]
  1. Run npm update and restart your Hubot.

Consult the upgrading guide for instructions on migrating from older major versions.

Commands

By default, saying anything at all in chat trains the model. The robot is always watching!

Hubot: markov will randomly generate text based on the current contents of its model.

Hubot: markov your mother is a will generate a random phrase seeded with the phrase you give it. This command might output "your mother is a classy lady", for example. Remember: Hubot is an innocent soul, and what he says only acts as a mirror for everything in your hearts.

Hubot: remarkov and Hubot: mmarkov are similar, but traverse node transitions in different directions: remarkov chains backwards from a given ending state, and mmarkov chains both forward and backward.

Configuration

The Hubot markov model can optionally be configured by setting environment variables:

  • HUBOT_MARKOV_DEFAULT_MODEL (default: true) controls the inclusion of the default, forward-chaining model that learns from all text messages. Set this to false to omit the default model and disable the markov and mmarkov commands.

  • HUBOT_MARKOV_REVERSE_MODEL (default: true) controls the inclusion of the reverse model. Setting this to false saves some space in your database, but doesn't let you use remarkov or mmarkov.

  • HUBOT_MARKOV_PLY (default: 1) controls the order of the default models that are built; effectively, how many previous states (words) are considered to choose the next state. You can bump this up if you'd like, but the default of 1 is both economical with storage and maximally hilarious.

  • HUBOT_MARKOV_LEARN_MIN (default: 1) controls the minimum length of a phrase that will be used to train the default models. Set this higher to avoid training your model with a bunch of immediate terminal transitions like "lol".

  • HUBOT_MARKOV_GENERATE_MAX (default: 50) controls the maximum size of a markov chain that will be generated by the markov, remarkov, and mmarkov commands.

  • HUBOT_MARKOV_STORAGE (default: memory) controls the backing storage used to persist the default models. Choices include:

    • memory, the default, which stores transitions entirely in-process (lost on restart);
    • redis, which stores data in a Redis cache; or
    • postgres, which stores data in a PostgreSQL database.
  • HUBOT_MARKOV_STORAGE_URL supplies additional configuration required by the redis and postgres storage backends. The formats are redis://${USER}:${PASSWORD}@${HOSTNAME}:${PORT}/${DBNUM} and postgres://${USER}:${PASSWORD}@${HOSTNAME}:${PORT}/${DATABASE} with defaults omitted.

  • HUBOT_MARKOV_RESPOND_CHANCE controls the chance that Hubot will respond un-prompted to a message it sees by using the last word in the message as the seed. Set this to a value between 0 and 1.0 to enable the feature. Leaving this variable unset or setting it to 0 will disable the feature.

  • HUBOT_MARKOV_INCLUDE_URLS (default: false) will default to ignoring messages that include URLs from the default models.

  • HUBOT_MARKOV_IGNORELIST (default: empty) is interpreted as a comma-separated list of usernames to ignore for purposes of markov indexing. You can use this to prevent the output of other bots or integrations from clogging up your model.

  • HUBOT_MARKOV_IGNORE_MESSAGE_LIST (default: empty) is interpreted as a comma-separated list of sub-phrases to ignore from default and reverse models. Is a basic substring match for every message. Use this to ignore terms, like your bot's username

  • HUBOT_MARKOV_LEARNING_LISTEN_MODE - (default: 'catch-all') change the robot.listen mode for learning, helpful if you have other plugins that interfere with robot.catchAll. Options:

    • 'catch-all', learn message if no other scripts process message.
    • 'hear-all', learn every message, regardless if another script handled it.
    • If set to another value, will use it as a robot.listen regex pattern
  • HUBOT_MARKOV_RESPOND_LISTEN_MODE - (default: 'catch-all') change the robot.listen mode for responding, helpful if you have other plugins that interfere with robot.catchAll. Options:

    • 'catch-all', learn message if no other scripts process message.
    • 'hear-all', learn every message, regardless if another script handled it.
    • If set to another value, will use it as a robot.listen regex pattern

To re-use a PostgreSQL connection with other parts of your Hubot, define a robot method called getDatabase that returns the connection object. This package uses pg-promise.

Custom models

Store and generate text from arbitrary sources and in more complex commands by using the programmatic API available at robot.markov. Call robot.markov.createModel during script initialization to configure a model, then use robot.markov.modelNamed to access the model instance in commands that train it or generate from it.

Example: Manual Model

module.exports = (robot) ->
  MODELNAME = 'manual'

  # Create or connect to a model with all default options
  robot.markov.createModel MODELNAME

  robot.respond /modeladd\s+(.+)/, (msg) ->
    robot.markov.modelNamed MODELNAME, (model) ->
      model.learn msg.match[1], ->
        msg.reply 'Input accepted.'

  robot.respond /modelgen(?:\s+(.+))/, (msg) ->
    robot.markov.modelNamed MODELNAME, (model) ->
      model.generate msg.match[1] or '', 50, (output) ->
        msg.reply output

Example: Letter-Based Model

module.exports = (robot) ->
  MODELNAME = 'letters'

  # Create or connect to a model with a custom pre- and post-processor
  robot.markov.createModel MODELNAME, {}, (model) ->
    model.processWith
      pre: (input) -> input.split('')
      post: (output) -> output.join('')

  robot.catchAll (msg) ->
    # Filter out "lol"
    return if /^\s*l(o+)l\s*/.test msg.text

    robot.markov.modelNamed MODELNAME, (model) ->
      model.learn msg.text

  robot.respond /lettergen(?:\s+(.+))/, (msg) ->
    robot.markov.modelNamed MODELNAME, (model) ->
      model.generate msg.match[1] or '', 100, (output) ->
        msg.reply output

The full API is available in the docs/ directory.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].