{"id":13409524,"url":"https://github.com/kyleterry/tenyks","last_synced_at":"2025-04-09T09:07:56.206Z","repository":{"id":4418931,"uuid":"5556661","full_name":"kyleterry/tenyks","owner":"kyleterry","description":"The Tenyks IRC bot.","archived":false,"fork":false,"pushed_at":"2023-02-15T14:38:33.000Z","size":2347,"stargazers_count":176,"open_issues_count":12,"forks_count":19,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-02T06:09:39.682Z","etag":null,"topics":["bot","go","golang","irc","irc-bot","json-payload","tenyks"],"latest_commit_sha":null,"homepage":"http://tenyks.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kyleterry.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2012-08-26T02:02:24.000Z","updated_at":"2025-01-29T16:09:57.000Z","dependencies_parsed_at":"2023-07-05T17:00:46.077Z","dependency_job_id":null,"html_url":"https://github.com/kyleterry/tenyks","commit_stats":{"total_commits":376,"total_committers":5,"mean_commits":75.2,"dds":"0.061170212765957466","last_synced_commit":"db1fe24b9205a0270ac7ff9ed7f3a6725fa72831"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyleterry%2Ftenyks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyleterry%2Ftenyks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyleterry%2Ftenyks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyleterry%2Ftenyks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyleterry","download_url":"https://codeload.github.com/kyleterry/tenyks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008630,"owners_count":21032556,"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","go","golang","irc","irc-bot","json-payload","tenyks"],"created_at":"2024-07-30T20:01:01.635Z","updated_at":"2025-04-09T09:07:56.193Z","avatar_url":"https://github.com/kyleterry.png","language":"Go","funding_links":[],"categories":["Bot Building","Bot建设","Software Packages","Go","机器人相关` 构建和使用机器人的库`","软件包","軟件包","Uncategorized","机器人相关"],"sub_categories":["Other Software","Contents","其他软件","其他軟件","Free e-books"],"readme":"[![Build Status](https://travis-ci.org/kyleterry/tenyks.svg?branch=master)](https://travis-ci.org/kyleterry/tenyks)\n```Textile\n  _                   _         \n | |                 | |        \n | |_ ___ _ __  _   _| | _____  \n | __/ _ \\ '_ \\| | | | |/ / __| \n | ||  __/ | | | |_| |   \u003c\\__ \\  The IRC bot for hackers.\n  \\__\\___|_| |_|\\__, |_|\\_\\___/ \n                 __/ |          \n                |___/           \n```\n\nTenyks is a computer program designed to relay messages between connections to\nIRC networks and custom built services written in any number of languages.\nMore detailed, Tenyks is a service oriented IRC bot rewritten in Go.\nService/core communication is handled by ZeroMQ 4 PubSub via json payloads.\n\nThe core acts like a relay between IRC channels and remote services. When a\nmessage comes in from IRC, that message is turned into a json data structure,\nthen sent over the pipe on a Pub/Sub channel that services can subscribe to.\nServices then parse or pattern match the message, and possibly respond back via\nthe same method.\n\nThis design, while not anything new, is very flexible because one can write\ntheir service in any number of languages. The current service implementation\nused for proof of concept is written in Python. You can find that\n[here](https://github.com/kyleterry/tenyks-service). It's also beneficial because you can take down\nor bring up services without the need to restart the bot or implement a\ncomplicated hot pluggable core. Services that crash also don't run the risk of\ntaking everything else down with it.\n\n## Installation and whatnot\n\n### Building\n\nCurrent supported Go version is 1.7. All packages are vendored with Godep and\nstored in the repository. I update these occasionally. Make sure you have a\nfunctioning Go 1.7 environment.\n\n1. Install ZeroMQ4 (reference your OSs package install documentation) and make\n   sure libzmq exists on the system.\n1. `go get github.com/kyleterry/tenyks`\n1. `cd ${GOPATH}/src/github.com/kyleterry/tenyks`\n1. `make` - this will run tests and build\n1. `sudo make install` - otherwise you can find it in `./bin/tenyks`\n1. `cp config.json.example config.json`\n1. Edit `config.json` to your liking.\n\n### Uninstall\n\nWhy would you ever want to do that?\n\n```bash\ncd ${GOPATH}/src/github.com/kyleterry/tenyks\nsudo make uninstall\n```\n\n### Docker\n\nThere is a Docker image on Docker hub called `kyleterry/tenyks`. No\nconfiguration is available in the image so you need to use it as a base image.\nYou can pass your own configuration in like so:\n\n```docker\nFROM kyleterry/tenyks:latest\nCOPY my-config.json /etc/tenyks/config.json\n```\n\nThen you can build your image: `docker build -t myuser/tenyks .` and run it\nwith: `docker run -d -P --name tenyks myuser/tenyks`.\n\n### Binary Release\n\nYou can find binary builds on [bintray](https://dl.bintray.com/kyleterry/tenyks/).\n\nI cross compile for Linux {arm,386,amd64} and Darwin {386,amd64}.\n\n### Configuration\n\nConfiguration is just json. The included example contains everything you need to\nget started. You just need to swap out the server information.\n\n```bash\ncp config.json.example ${HOME}/tenyks-config.json\n```\n\n### Running\n\n`tenyks ${HOME}/tenyks-config.json`\n\nIf a config file is excluded when running, Tenyks will look for configuration\nin `/etc/tenyks/config.json` first, then\n`${HOME}/.config/tenyks/config.json` then it will give up. These are defined\nin tenyks/tenyks.go and added with ConfigSearch.AddPath(). If you feel more\npaths should be searched, please feel free to add it and submit a pull request.\n\n### Vagrant\n\nIf you want to play _right fucking now_, you can just use vagrant: `vagrant up`\nand then `vagrant ssh`. Tenyks should be built and available in your `$PATH`.\nThere is also an IRC server running you can connect to server on `192.168.33.66` with your IRC client.\n\nJust run `tenyks \u0026 \u0026\u0026 disown` from the vagrant box and start playing.\n\n## Testing\n\nI'm a horrible person. ~~There aren't tests yet. I'll get right on this...~~.\nThere are only a few tests.\n\n## Builtins\n\nTenyks comes with very few commands that the core responds to directly. You can\nget a list of services and get help for those services.\n\n`tenyks: !services` will list services that have registered with the bot\nthrough the service [registration API.](#service-registration).  \n`tenyks: !help` will show a quick help menu of all the commands available to\ntenyks.  \n`tenyks: !help servicename` will ask the service to sent their help message to\nthe user.\n\n## Services\n\n### Libraries\n* [tenyksservice](https://github.com/kyleterry/tenyks-service) (Python)\n* [quasar](https://github.com/kyleterry/quasar) (Go)\n\n### To Services\n\nExample JSON payload sent to services:\n\n```json\n{\n    \"target\":\"#tenyks\",\n    \"command\":\"PRIVMSG\",\n    \"mask\":\"unaffiliated/vhost-\",\n    \"direct\":true,\n    \"nick\":\"vhost-\",\n    \"host\":\"unaffiliated/vhost-\",\n    \"full_message\":\":vhost-!~vhost@unaffiliated/vhost- PRIVMSG #tenyks :tenyks-demo: weather 97217\",\n    \"user\":\"~vhost\",\n    \"from_channel\":true,\n    \"connection\":\"freenode\",\n    \"payload\":\"weather 97217\",\n    \"meta\":{\n        \"name\":\"Tenyks\",\n        \"version\":\"1.0\"\n    }\n}\n```\n\n### To Tenyks for IRC\n\nExample JSON response from a service to Tenyks destined for IRC\n\n```json\n{\n    \"target\":\"#tenyks\",\n    \"command\":\"PRIVMSG\",\n    \"from_channel\":true,\n    \"connection\":\"freenode\",\n    \"payload\":\"Portland, OR is 63.4 F (17.4 C) and Overcast; windchill is NA; winds are Calm\",\n    \"meta\":{\n        \"name\":\"TenyksWunderground\",\n        \"version\":\"1.1\"\n    }\n}\n```\n\n### Service Registration\n\nRegistering your service with the bot will let people ask Tenyks which services\nare online and available for use. Registering is not requires; anything\nlistening on the pubsub channel can respond without registration.\n\nEach service should have a unique UUID set in it's REGISTER message. An example\nof a valid register message is below:\n\n```json\n{\n    \"command\":\"REGISTER\",\n    \"meta\":{\n        \"name\":\"TenyksWunderground\",\n        \"version\":\"1.1\",\n        \"UUID\": \"uuid4 here\",\n        \"description\": \"Fetched weather for someone who asks\"\n    }\n}\n```\n\n### Service going offline\n\nIf the service is shutting down, you should send a BYE message so Tenyks doesn't\nhave to timeout the service after PINGs go unresponsive:\n\n```json\n{\n    \"command\":\"BYE\",\n    \"meta\":{\n        \"name\":\"TenyksWunderground\",\n        \"version\":\"1.1\",\n        \"UUID\": \"uuid4 here\",\n        \"description\": \"Fetched weather for someone who asks\"\n    }\n}\n```\n\n### Commands for registration that go to services\n\nServices can register with Tenyks. This will allow you to list the services\ncurrently online from the bot. This is not persistent. If you shut down the bot,\nthen all the service UUIDs that were registered go away.\n\nThe commands sent to services are:\n\n```json\n{\n  \"command\": \"HELLO\",\n  \"payload\": \"!tenyks\"\n}\n```  \n`HELLO` will tell services that Tenyks has come online and they can register if\nthey want to.\n\n```json\n{\n  \"command\": \"PING\",\n  \"payload\": \"!tenyks\"\n}\n```  \n`PING` will expect services to respond with `PONG`.\n\nList and Help commands are coming soon.\n\n### Lets make a service!\n\nThis service is in python and uses the\n[tenyks-service](https://github.com/kyleterry/tenyks-service) package. You can\ninstall that with pip: `pip install tenyksservice`.\n\n```python\nfrom tenyksservice import TenyksService, run_service, FilterChain\n\n\nclass Hello(TenyksService):\n    irc_message_filters = {\n        'hello': FilterChain([r\"^(?i)(hi|hello|sup|hey), I'm (?P\u003cname\u003e(.*))$\"],\n                             direct_only=False),\n        # This is will respond to /msg tenyks this is private\n        'private': FilterChain([r\"^this is private$\"],\n                             private_only=True)\n    }\n\n    def handle_hello(self, data, match):\n        name = match.groupdict()['name']\n        self.logger.debug('Saying hello to {name}'.format(name=name))\n        self.send('How are you {name}?!'.format(name=name), data)\n\n    def handle_private(self, data, match):\n        self.send('Hello, private message sender', data)\n\n\ndef main():\n    run_service(Hello)\n\n\nif __name__ == '__main__':\n    main()\n```\n\nOkay, we need to generate some settings for our new service.\n\n```bash\ntenyks-service-mkconfig hello \u003e\u003e hello_settings.py\n```\n\nNow lets run it: `python main.py hello_settings.py`\n\nIf you now join the channel that tenyks is in and say \"tenyks: hello, I'm Alice\"\nthen tenyks should respond with \"How are you Alice?!\".\n\n### More Examples\n\nThere is a repository with some services on my Github called\n[tenyks-contrib](https://github.com/kyleterry/tenyks-contrib). These are all\nusing the older tenyksclient class and will probably work out of the box with\nTenyks. I'm going to work on moving them to the newer\n[tenyks-service](https://github.com/kyleterry/tenyks-service) class.\n\nA good example of something more dynamic is the [Weather\nservice](https://github.com/kyleterry/tenyks-contrib/blob/master/src/tenykswunderground/main.py).\n\n## Credit where credit is due\n\nService oriented anything isn't new. This idea came from an old\n[coworker](https://github.com/wraithan) of mine. I just wanted to do something\nslightly different. There are also plenty of other plugin style bots (such as\nhubot and eggdrop). Every open source project needs love, so check those out as\nwell.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyleterry%2Ftenyks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyleterry%2Ftenyks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyleterry%2Ftenyks/lists"}