{"id":21968469,"url":"https://github.com/robertgzr/joe-telegram-adapter","last_synced_at":"2025-03-22T22:17:09.403Z","repository":{"id":100044854,"uuid":"207242142","full_name":"robertgzr/joe-telegram-adapter","owner":"robertgzr","description":"Telegram adapter for the Joe bot library","archived":false,"fork":false,"pushed_at":"2021-06-26T23:43:21.000Z","size":25,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T01:48:09.948Z","etag":null,"topics":["bot","chat","joe","telegram"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertgzr.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-09T06:43:34.000Z","updated_at":"2022-10-29T20:21:35.000Z","dependencies_parsed_at":"2023-06-19T01:43:02.084Z","dependency_job_id":null,"html_url":"https://github.com/robertgzr/joe-telegram-adapter","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertgzr%2Fjoe-telegram-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertgzr%2Fjoe-telegram-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertgzr%2Fjoe-telegram-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertgzr%2Fjoe-telegram-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertgzr","download_url":"https://codeload.github.com/robertgzr/joe-telegram-adapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245026042,"owners_count":20549073,"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","chat","joe","telegram"],"created_at":"2024-11-29T13:56:06.945Z","updated_at":"2025-03-22T22:17:09.379Z","avatar_url":"https://github.com/robertgzr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eJoe Bot - Telegram Adapter\u003c/h1\u003e\n\u003cp align=\"center\"\u003eConnecting joe with the Telegram chat application. https://github.com/go-joe/joe\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://github.com/robertgzr/joe-telegram-adapter/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/tag/robertgzr/joe-telegram-adapter.svg?label=version\u0026color=brightgreen\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://godoc.org/github.com/robertgzr/joe-telegram-adapter\"\u003e\u003cimg src=\"https://img.shields.io/badge/godoc-reference-blue.svg?color=blue\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\nThis repository contains a module for the [Joe Bot library][joe]. Built using \n[telegram-bot-api][tgbotapi].\n\n## Getting Started\n\nThis library is packaged using [Go modules][go-modules]. You can get it via:\n\n```\ngo get github.com/robertgzr/joe-telegram-adapter\n```\n\n### Example usage\n\nIn order to connect your bot to telegram you can simply pass it as module when\ncreating a new bot:\n\n```go\npackage main\n\nimport (\n\t\"github.com/go-joe/joe\"\n\t\"github.com/robertgzr/joe-telegram-adapter\"\n)\n\nfunc main() {\n\tb := joe.New(\"example-bot\",\n\t\ttelegram.Adapter(os.Getenv(\"TELEGRAM_BOT_TOKEN\")),\n\t\t…\n\t)\n\t\n\tb.Respond(\"ping\", Pong)\n\n\terr := b.Run()\n\tif err != nil {\n\t\tb.Logger.Fatal(err.Error())\n\t}\n}\n```\n\nFor how to create a telegram bot and connect to it, [see here](https://core.telegram.org/bots#3-how-do-i-create-a-bot).\n\nThis adapter will emit the following events to the robot brain:\n\n- `joe.ReceiveMessageEvent`\n- `ReceiveCommandEvent`\n\nA common use-case is handling Telegram bot commands, `/command`. To make this \neasy a custom event type is emitted:\n\n```go\npackage main\n\nimport (\n\t\"github.com/go-joe/joe\"\n\t\"github.com/robertgzr/joe-telegram-adapter\"\n)\n\ntype ExampleBot {\n    *joe.Bot\n}\n\nfunc main() {\n\tb := \u0026ExampleBot{\n\t    Bot: joe.New(\"example-bot\",\n\t\t    telegram.Adapter(os.Getenv(\"TELEGRAM_BOT_TOKEN\")),\n\t\t    …\n\t    ),\n\t}\n\n\tb.Brain.RegisterHandler(b.HandleTelegramCommands)\n\tb.Respond(\"ping\", Pong)\n\n\terr := b.Run()\n\tif err != nil {\n\t\tb.Logger.Fatal(err.Error())\n\t}\n}\n\nfunc (b *ExampleBot) HandleTelegramCommands(ev telegram.ReceiveCommandEvent) error {\n\tswitch ev.Arg0 {\n\tcase \"command\":\n\t\tb.Say(ev.Channel(), \"Hello, world!\")\n\t\treturn nil\n\tdefault:\n\t\treturn errors.New(\"unknown command\")\n\t}\n}\n```\n\n\n## Additional features\n\nSome features available via the [Bot API][tgbotapi] is *nice to have* when writing\nbots:\n\n```go\ntg, ok := Bot.Adapter.(*telegram.TelegramAdapter)\n```\n\n`tg.BotAPI` allows full access to the Bot API interface.\n\nThis package also provides some abstractions for ease of use:\n\n```\n// photo/gif/sticker can be file, FileReader, or FileBytes which will upload a\n// new instance; or a string which assumes a telegram fileID\ntg.SendPhoto(msg.Channel, photo, \"caption\")\ntg.SendGif(msg.Channel, gif, \"caption\")\ntg.SendSticker(msg.Channel, sticker)\n```\n\n## License\n\n[BSD-3-Clause](LICENSE)\n\n[joe]: https://github.com/go-joe/joe\n[tgbotapi]: https://github.com/go-telegram-bot-api/telegram-bot-api\n[go-modules]: https://github.com/golang/go/wiki/Modules\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertgzr%2Fjoe-telegram-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertgzr%2Fjoe-telegram-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertgzr%2Fjoe-telegram-adapter/lists"}