{"id":13493217,"url":"https://github.com/gesteves/snarkov","last_synced_at":"2025-04-12T17:42:39.930Z","repository":{"id":2390469,"uuid":"21447143","full_name":"gesteves/snarkov","owner":"gesteves","description":"A hilarious Sinatra-based Markov bot for Slack.","archived":false,"fork":false,"pushed_at":"2023-03-16T05:38:25.000Z","size":161,"stargazers_count":26,"open_issues_count":6,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-02-15T07:32:32.206Z","etag":null,"topics":["bot","heroku","markov-bot","ruby","sinatra","slack"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gesteves.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-07-03T02:22:19.000Z","updated_at":"2022-11-21T03:21:44.000Z","dependencies_parsed_at":"2023-07-11T07:47:27.072Z","dependency_job_id":null,"html_url":"https://github.com/gesteves/snarkov","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gesteves%2Fsnarkov","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gesteves%2Fsnarkov/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gesteves%2Fsnarkov/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gesteves%2Fsnarkov/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gesteves","download_url":"https://codeload.github.com/gesteves/snarkov/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248608400,"owners_count":21132721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","heroku","markov-bot","ruby","sinatra","slack"],"created_at":"2024-07-31T19:01:13.271Z","updated_at":"2025-04-12T17:42:39.909Z","avatar_url":"https://github.com/gesteves.png","language":"Ruby","readme":"# snarkov\n\nSnarkov is a Sinatra-based [Markov bot][mb] for [Slack][slack].\n\n![](http://i.imgur.com/HJI9SLK.png)\n\n[mb]: http://stackoverflow.com/questions/5306729/how-do-markov-chain-chatbots-work\n[slack]: https://slack.com\n\n## Installation\n\nThe simplest way to set up snarkov is using [Heroku][he]. Just press this button to deploy it:\n\n[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)\n\nYou'll need to set up a Slack [outgoing webhook][ow] to send messages to snarkov. Set it up so it listens to a single channel of your choice, _don't_ set up a keyword. Copy the integration's token, you'll need it to deploy the app. You'll also need a Slack API token. You can get one by going to [this page][token] while logged into Slack. Once you have everything in place, deploy the app, then set the outgoing webhook's url to `https://[your-heroku-app].herokuapp.com/markov`, and save it.\n\n[he]: http://www.heroku.com\n[ow]: https://slack.com/services/new/outgoing-webhook\n[token]: https://api.slack.com/web\n\n\n## Importing channels\n\nSnarkov works better if it has a lot of text to work with. To help populate it, you can feed it the entire history of a list of Slack channels. **Warning:** Depending on how many messages are in the channel's history, this might take a long time, and potentially fill up your free Heroku Redis account very quickly. You'll probably want to go to your Heroku dashboard and upgrade your Redis plan to one of the paid levels before doing this, or use the `DAYS` option to limit the amount of text you're importing.\n\nTo populate redis in production, install the [Heroku Toolbelt](https://toolbelt.heroku.com) and run:\n\n```\n$ heroku run rake ingest CHANNELS='#channel-name' --app your-heroku-app-name\n```\n\nThe `ingest` task takes a single channel name, or a comma-separated list of channel names, e.g.:\n\n```\n$ heroku run rake ingest CHANNELS='#random,#general' --app your-heroku-app-name\n```\n\nIf you want to import a channel's history going back only a certain number of days, you can add a `DAYS` option. For example:\n\n```\n$ heroku run rake ingest CHANNELS='#random,#general' DAYS=5 --app your-heroku-app-name\n```\n\nThis will import the last 5 days of chat history from the #random and #general channels.\n\nIf you only want to import a certain user's messages, use the `USERNAME` option. For example:\n\n```\n$ heroku run rake ingest CHANNELS='#random,#general' USERNAME=\"guille\" --app your-heroku-app-name\n```\n\n## Usage\n\nAfter snarkov is up and running, the outgoing webhook you set up will send every message in the channel you selected (except those from other integrations) to snarkov, which will process and store it for future usage. It might respond with a Markov-generated message of its own, depending on the number you have set in the `RESPONSE_CHANCE` environment variable, with 0 meaning it will never respond, and 1 meaning it'll respond every single time.\n\nIf you have a Mac, a fun thing to do is run this in the terminal:\n\n```\n$ curl -s http://[your-heroku-app]/markov?token=[outgoing-webhook-token] | say -i\n```\n\n## Running locally\n\n1. Install redis\n2. Create a `.env` file and put the config variables there (see `.env.example`)\n3. Run `bundle install`\n4. Run `foreman start -f Procfile.dev`\n5. Send POST requests to `http://localhost:5000/markov` to populate it, with the `text` parameter being the message's text, and `token` the outgoing webhook's token.\n6. Send GET requests to `http://localhost:5000/markov?token=[OUTGOING_WEBHOOK_TOKEN]` to see a random reply\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## License\n\nCopyright (c) 2014, Guillermo Esteves\nAll rights reserved.\n\nBSD license\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\n3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","funding_links":[],"categories":["Service Integration",":gear: \u0026nbsp; Open-Source Slack Apps and Integrations"],"sub_categories":["Ruby"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgesteves%2Fsnarkov","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgesteves%2Fsnarkov","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgesteves%2Fsnarkov/lists"}