{"id":13710733,"url":"https://github.com/DazFather/parrbot","last_synced_at":"2025-05-06T19:32:29.759Z","repository":{"id":37820301,"uuid":"424880562","full_name":"DazFather/parrbot","owner":"DazFather","description":"Parr(B)ot is a Telegram bot framework based on top of Echotron","archived":false,"fork":false,"pushed_at":"2023-01-15T14:21:17.000Z","size":3764,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-13T21:44:33.657Z","etag":null,"topics":["echotron","framework","go","golang","telegram-bot"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DazFather.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":"2021-11-05T08:42:41.000Z","updated_at":"2023-07-20T07:59:27.000Z","dependencies_parsed_at":"2023-02-09T22:31:06.755Z","dependency_job_id":null,"html_url":"https://github.com/DazFather/parrbot","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/DazFather%2Fparrbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DazFather%2Fparrbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DazFather%2Fparrbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DazFather%2Fparrbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DazFather","download_url":"https://codeload.github.com/DazFather/parrbot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252753719,"owners_count":21798999,"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":["echotron","framework","go","golang","telegram-bot"],"created_at":"2024-08-02T23:01:00.340Z","updated_at":"2025-05-06T19:32:24.739Z","avatar_url":"https://github.com/DazFather.png","language":"Go","readme":"# Parr(B)ot framework\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/DazFather/Parrbot)](https://goreportcard.com/report/github.com/DazFather/Parrbot)\n[![Go Reference](https://pkg.go.dev/badge/github.com/DazFather/parrbot.svg)](https://pkg.go.dev/github.com/DazFather/parrbot)\n[![Telegram](https://img.shields.io/badge/Parr(B)ot%20News-blue?logo=telegram\u0026style=flat)](https://t.me/+3_LBajtkqUgzOTFk)\n\nA just born Telegram bot framework in [Go](https://golang.org) built on top of the [echotron library](https://github.com/NicoNex/echotron).\n\u003e You can call it Parrot, Parr-Bot, Parrot Bot, is up to you\n\n\n## Philosophy and Design\n\n**Framework** not library: Parr(B)ot main focus is to help you to better organize your code in a way that is highly scalable and reusable.\nLibraries are cool but if not used carefully tends to transform your code into an extremely difficult to debug spaghetti-code monster.\n\u003e _Framework is like the nest of your project_ 🦜\n\n**Modular**: Modules helps developer to access, reuse and expand their codes and also give a sense of order to your project that will help in the long run. The base structure of Parr(b)ot is design to be easy to maintain in the future\n\u003e _Put together some code and a pair of wings to build your own robo-parrot_ 🦜\n\n**Typed**: We love types! They allows you to write solid codes and if the language is (like Go) compiled you will not need to do any runtime checking of the entry values.\nThat said sometimes having access to many types and constructor can be overwhelming this is the reason why the interface can be very handy to manage different data-structure that have similar behavior.\nYou can find an example of what we mean on the \"incoming.go\" file (inside the \"message\" module).\n\u003e _We think that biodiversity is great_ 🦜\n\n**Customizable**: The parr(b)ot modules are not made to be untouched but the exact opposite. User is more then welcome to change the framework behavior in order for example to extend a module with more useful functions or types, to change the information carried by the Bot or to initialize the bot in a different way. Is up to you.\nThe framework will try to guide you using comments and naming to go at the level of deepness that you desire\n\u003e _Explore the jungle, dangerous but fun_ 🦜\n\n### Main features\n\n_Okay, cool but what it does actually mean? How does all of this translate in something useful for me? Why should I use Parr(B)ot?_\nIt's time to talk about the main features of this framework:\n - **Linear design**: each command in Parr(B)ot can return a message that will be automatically sent. Althow you can still return nil and send a message meanwhile, this type of approach wants to invite user to have a function that returns a message when needed, in this way if something goes wrong (message is wrong or not appear) is easier to identify and locate the bug and makes your code more organized\n - **Edit-on-sync**: when sending a request to Telegram to edit an message, if everything will go right the same edits will be applied on the message variable that you used to send the request too, to reduce the instantiation of new variables and help you to keep tracks of the changes without loosing anything on the way\n - **Ready to go**: Parr(B)ot helps user to quickly creates Telegram idiomatic commands, by encouraging usage of triggers that start with a '/' and filling the command description right away, on top of that the framework will also care about managing the Telegram Bot API TOKEN, without any need to hardcode it and difficulties when making the code public.\n - **Here to help**: lots of utilities to help you achive what you want faster, without warring about common stuffs like creating a menu system, run your /commands when they are supposed to, managing some buttons. Parr(B)ot already did all these things for you\n\n_...and more are coming_\n\n## Documentation\n\n[Here](https://pkg.go.dev/github.com/DazFather/parrbot) there is the official documentation of parrbot. As you will see is divided in 3 main packages / directories:\n - [message](https://pkg.go.dev/github.com/DazFather/parrbot/message) - (Core) manage incoming / outgoing message-related stuffs\n - [robot](https://pkg.go.dev/github.com/DazFather/parrbot/robot) - (Core) manage bots sessions and commands\n - [tgui](https://pkg.go.dev/github.com/DazFather/parrbot/tgui) - toolkit for user interfaces like menus or keyboards utilities\n\nParr(B)ot makes massively use of the [echotron library](https://pkg.go.dev/github.com/NicoNex/echotron/v3), it might be useful also it's doc. Keep in mind that the echotron library is almost 1:1 with the Telegram's Bot API, if you are unsure about the meaning of certain fields you can always have a look to the [Telegram's doc](https://core.telegram.org/bots/api).\n\n## Usage\n\n - **Step 1. Import or clone Parr(B)ot** - There are two main ways to use Parr(B)ot: cloning the repo or via _import_ of the needed package simply like this: `import \"github.com/DazFather/parrbot/\u003cpackage\u003e\"`. Notice that \"`message`\" and \"`robot`\" packages contains core functionality.\n\u003e Make sure you have Go installed. You can check the required version on the [go.mod](./go.mod) file (keep [this](https://go.dev/doc/go1compat) in mind). The Go's official [guide for managing dependency](https://go.dev/doc/modules/managing-dependencies) might be useful too\n\n - **Step 2. Create your own awesome bot** - Use the function robot.Start and fill it with a list of robot.Command that the bot will execute when triggered\n\u003e Check out [main.go](./main.go) for a usage example\n\n - **Step 3. Make it fly!** - After building your project, run the bot and use as argument the API TOKEN, or save it on a _\".txt\"_ file and use `--readfrom` followed by the file path.\n\u003e You can get the Telegram's Bot API TOKEN by creating a bot using [@BotFather](https://t.me/BotFather)\n\n\n## Example\n\n**Hello world** - A simple bot that send 'Hello World!' when user send '/start' to it in a private chat.\nThe bot will also have to create the command interface for Telegram\n\n```golang\n// PARR(B)OT VERSION\npackage main\n\nimport (\n    \"github.com/DazFather/parrbot/message\" // (Core) Incoming / Outgoing message-related things\n    \"github.com/DazFather/parrbot/robot\"   // (Core) Parr(B)ot core functionality\n)\n\nfunc main() {\n    robot.Start(robot.Command{{       // start the bot with the following command\n        Description: \"Start the bot\", // command's description that will appear on the menu\n        Trigger:     \"/start\",        // text that will trigger the command\n        ReplyAt:     message.MESSAGE, // this command will only reply to normal messages\n        CallFunc:    func (bot *robot.Bot, update *message.Update) message.Any { // when triggered call this function\n            return message.Text{\"Hello World\", nil} // ...that returns a textual message containing \"Hello World\"\n        },\n    })\n}\n```\n\n```golang\n// VANILLA ECHOTRON VERSION\npackage main\n\nimport (\n\t\"log\"\n\t\"time\"\n\n\t\"github.com/NicoNex/echotron/v3\"\n)\n\ntype bot struct {\n\tchatID int64\n}\n\nconst token = \"YOUR TELEGRAM TOKEN\"\n\nvar (\n    dsp *echotron.Dispatcher\n    api echotron.API\n)\n\nfunc newBot(chatID int64) echotron.Bot {\n\tbot := \u0026bot{chatID}\n\tgo bot.selfDestruct(time.After(time.Hour * 2))\n\treturn bot\n}\n\nfunc (b *bot) selfDestruct(timech \u003c-chan time.Time) {\n\t\u003c-timech\n\tdsp.DelSession(b.chatID)\n}\n\nfunc (b *bot) Update(update *echotron.Update) {\n\tif update.Message.Text == \"/start\" {\n\t\tapi.SendMessage(\"Hello world\", b.chatID, nil)\n\t}\n}\n\nfunc main() {\n    api = echotron.NewAPI(token)\n    dsp = echotron.NewDispatcher(token, newBot)\n\n    api.SetMyCommands(nil, echotron.BotCommand{\n        Command:     \"/start\",\n        Description: \"Start the bot\",\n    })\n\n\tlog.Println(dsp.Poll())\n}\n```\n\n---\n\nYou can find a more detailed example on [main.go](./main.go) file or by visiting a complete bot made by other users in the [used by section](https://github.com/DazFather/parrbot/network/dependents?package_id=UGFja2FnZS0yOTE2NzIwMTcy)\n","funding_links":[],"categories":["Repositories"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDazFather%2Fparrbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDazFather%2Fparrbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDazFather%2Fparrbot/lists"}