{"id":19494687,"url":"https://github.com/ceejbot/opsbot","last_synced_at":"2025-04-25T21:31:57.926Z","repository":{"id":15053874,"uuid":"17780014","full_name":"ceejbot/opsbot","owner":"ceejbot","description":"the npm operations chatbot is fully operational","archived":false,"fork":false,"pushed_at":"2022-05-12T16:53:23.000Z","size":252,"stargazers_count":15,"open_issues_count":53,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-06T22:52:04.334Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ceejbot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-15T16:38:35.000Z","updated_at":"2022-01-10T09:31:32.000Z","dependencies_parsed_at":"2022-09-18T20:52:39.127Z","dependency_job_id":null,"html_url":"https://github.com/ceejbot/opsbot","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fopsbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fopsbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fopsbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fopsbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ceejbot","download_url":"https://codeload.github.com/ceejbot/opsbot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224018310,"owners_count":17242046,"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":[],"created_at":"2024-11-10T21:32:05.567Z","updated_at":"2024-11-10T21:33:02.497Z","avatar_url":"https://github.com/ceejbot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# opsbot\n\nHermione the npm operations [Slack](https://slack.com) chat battlestation is fully operational and is capable of demonstrating its power on a target, a military target. Name the system!\n\n[![on npm](http://img.shields.io/npm/v/opsbot.svg?style=flat)](https://www.npmjs.org/package/opsbot)  [![Tests](http://img.shields.io/travis/ceejbot/opsbot.svg?style=flat)](http://travis-ci.org/ceejbot/opsbot) [![Coverage Status](https://coveralls.io/repos/github/ceejbot/opsbot/badge.svg?branch=master)](https://coveralls.io/github/ceejbot/opsbot?branch=master)  [![Dependencies](http://img.shields.io/david/ceejbot/opsbot.svg?style=flat)](https://david-dm.org/ceejbot/opsbot)\n\n## deploying\n\nYou'll want to create your own little node package for your installation. This package needs a `package.json`, a configuration file, and a shell script to run the bot.\n\nHere's a nice minimal package.json, requiring opsbot \u0026 a third-party plugin:\n\n```json\n{\n  \"name\": \"deathstar\",\n  \"version\": \"0.0.0\",\n  \"description\": \"a bot of destruction\",\n  \"scripts\": {\n    \"start\": \"opsbot config.js\",\n    \"dev\": \"NODE_ENV=dev opsbot testconfig.js\"\n  },\n  \"dependencies\": {\n    \"opsbot\": \"~3.0.0\",\n    \"opsbot-owl\": \"^0.0.1\"\n  }\n}\n```\n\nTo create your configuration file, start by copying [config.example.js](https://github.com/ceejbot/opsbot/blob/master/config.example.js). Edit to your taste. You can have it log to console and/or log to a file depending on how you want to keep its logs. `npm start` runs the bot in prod mode. `npm run dev` will run it with pretty-printed console output.\n\nList the plugins you want to load as fields in the `plugins` hash. The value should be an object with any required configuration for the plugin. Note that opsbot can load both built-in plugins and plugins installed via npm.\n\nExample configuration:\n\n```json\n{\n\tbotname: \"hermione\",\n\tadmin_channel: \"your-admin-channel-id\",\n\tbrain: { dbpath: \"./db\" },\n\tplugins:\n\t{\n\t\tbartly:\n\t\t{\n\t\t\tapikey: \"your-bart-api-key\",\n\t\t\tstation: \"powl\",\n\t\t\ttzOffset: 420,\n\t\t},\n\t}\n}\n```\n\nCreate a Slack bot and copy its API key. You must provide that key in the environment variable `SLACK_TOKEN`. One way to do that is to create a `.env` file containing the text `SLACK_TOKEN=your-token-here`. Opsbot will read that file if it's present.\n\n\n## built-in commands\n\n`botname: help`: return a help message\n\n`botname: status`: gives bot uptime, loaded plugins, and location of the bot's brain.\n\n## writing plugins\n\nPlugs in are [yargs command modules](http://yargs.js.org/docs/#methods-commandmodule). To write a plugin, write a yargs command and then load it into opsbot via config. The handler for the yargs command has an object with all the usual yargs parsed items in it, plus a `reply()` function that can be called as many times as you wish to post messages to the Slack channel the original command came from.\n\n`reply('string of text')` posts the given string of text.\n\n`reply(messsageObj)` posts a message as formatted according to the [Slack message API](https://api.slack.com/methods/chat.postMessage).\n\nHere's very boring plugin.\n\n```javascript\nfunction builder(yargs) {}\n\nfunction handler(argv)\n{\n\targv.reply('https://cldup.com/5B3kURG8aE.jpg');\n}\n\nmodule.exports = {\n\tcommand: 'ORLY \u003ctext...\u003e',\n\tdescribe: 'If you say ORLY?, you get the obvious response.',\n\tbuilder: builder,\n\thandler: handler\n};\n```\n\nLet's suppose we've published this on npm as `opsbot-owl`. To load this epic chatbot feature, you'd add the module as a dependency of your bot package and then mention it in the config like this:\n\n```json\n{\n\tbotname: \"wol\",\n\tadmin_channel: \"your-admin-channel-id\",\n\tplugins:\n\t{\n\t\t\"opsbot-owl\": true\n\t}\n}\n```\n\n## Provided plugins\n\n__bartly:__ Real-time BART departure information by station. Requires an API key and, of all things, a timezone offset.\n__flip:__ Table flip!  \n__rageflip:__ Really table flip!  \n__karma:__ Give points and take them away. Requires a database.\n__npm:__ Fetch package information from npm.  \n__statuscats:__ Show an [http status cat](http://http.cat).  \n__statuscats:__ Show an [http status dog](http://httpstatusdogs.com).  \n__morph:__ Morph one word into another using a nice short path.  \n\nEach plugin has more documentation at the top of its source file.\n\n## Plugin storage\n\nOpsbot uses [levelup](https://github.com/rvagg/node-levelup) to provide a persistent key/value brain to plugins. Each plugin is, on construction, given an options object with a sublevel-namespaced db object in the `brain` field. This object might not be available if the opsbot configuration hasn't given it a path to store the db in, so your plugin should assert if it requires the brain but is not given one. See an example in the built-in `karma` plugin.\n\n## Contributing\n\nWrite more plugins, add features to the existing plugins, it's all good.\n\nPlease follow the code style in existing files. `npm run lint` catches style problems as well as bugs. `xo --fix` might or might not actually fix them. If you write your own plugins, I don't much care what you do. Please try to be at least as responsible as I have been about writing tests.\n\nIf you want to use promises, go ahead! [bluebird](https://github.com/petkaantonov/bluebird) is already in the package deps.\n\nIf you write a plugin for opsbot \u0026 publish it on npm, please let me know so I can link it here! It might also help to give it the keyword `opsbot` so other people can find it when they search.\n\n## License\n\n[ISC](http://opensource.org/licenses/ISC)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceejbot%2Fopsbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceejbot%2Fopsbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceejbot%2Fopsbot/lists"}