{"id":27402249,"url":"https://github.com/chatmail/rpc-client-go","last_synced_at":"2025-04-14T04:03:08.149Z","repository":{"id":65661790,"uuid":"595258723","full_name":"chatmail/rpc-client-go","owner":"chatmail","description":"Chatmail bindings for Golang","archived":false,"fork":false,"pushed_at":"2025-03-21T20:13:20.000Z","size":292,"stargazers_count":9,"open_issues_count":2,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-10T00:32:16.516Z","etag":null,"topics":["bindings","chatmail","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chatmail.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,"roadmap":null,"authors":null,"dei":null},"funding":{"custom":["https://delta.chat/en/contribute#donate-money"],"liberapay":"delta.chat","open_collective":"delta-chat"}},"created_at":"2023-01-30T18:10:47.000Z","updated_at":"2025-03-27T17:10:14.000Z","dependencies_parsed_at":"2023-02-17T06:40:32.269Z","dependency_job_id":"eb2b0a51-ea3d-47c1-95ae-a9265358346a","html_url":"https://github.com/chatmail/rpc-client-go","commit_stats":{"total_commits":259,"total_committers":3,"mean_commits":86.33333333333333,"dds":"0.12355212355212353","last_synced_commit":"754420f939499c878b9ee85b66348c2d3770affa"},"previous_names":["deltachat-bot/deltachat-rpc-client-go","chatmail/rpc-client-go"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatmail%2Frpc-client-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatmail%2Frpc-client-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatmail%2Frpc-client-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatmail%2Frpc-client-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chatmail","download_url":"https://codeload.github.com/chatmail/rpc-client-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819387,"owners_count":21166477,"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":["bindings","chatmail","go","golang"],"created_at":"2025-04-14T04:02:49.218Z","updated_at":"2025-04-14T04:03:08.139Z","avatar_url":"https://github.com/chatmail.png","language":"Go","funding_links":["https://delta.chat/en/contribute#donate-money","https://liberapay.com/delta.chat","https://opencollective.com/delta-chat"],"categories":[],"sub_categories":[],"readme":"# Chatmail API for Go\n\n![Latest release](https://img.shields.io/github/v/tag/deltachat/deltachat-rpc-client-go?label=release)\n[![Go Reference](https://pkg.go.dev/badge/github.com/deltachat/deltachat-rpc-client-go.svg)](https://pkg.go.dev/github.com/deltachat/deltachat-rpc-client-go)\n[![CI](https://github.com/deltachat/deltachat-rpc-client-go/actions/workflows/ci.yml/badge.svg)](https://github.com/deltachat/deltachat-rpc-client-go/actions/workflows/ci.yml)\n![Coverage](https://img.shields.io/badge/Coverage-72.0%25-brightgreen)\n[![Go Report Card](https://goreportcard.com/badge/github.com/deltachat/deltachat-rpc-client-go)](https://goreportcard.com/report/github.com/deltachat/deltachat-rpc-client-go)\n\nChatmail client \u0026 bot API for Golang.\n\n## Install\n\n```sh\ngo get -u github.com/deltachat/deltachat-rpc-client-go\n```\n\n### Installing deltachat-rpc-server\n\nThis package depends on a standalone Chatmail RPC server `deltachat-rpc-server` program that must be\navailable in your `PATH`. For installation instructions check:\nhttps://github.com/deltachat/deltachat-core-rust/tree/master/deltachat-rpc-server\n\n## Usage\n\nExample echo-bot that will echo back any text message you send to it:\n\n\u003c!-- MARKDOWN-AUTO-DOCS:START (CODE:src=./examples/echobot_full/echobot.go) --\u003e\n\u003c!-- The below code snippet is automatically added from ./examples/echobot_full/echobot.go --\u003e\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/deltachat/deltachat-rpc-client-go/deltachat\"\n\t\"github.com/deltachat/deltachat-rpc-client-go/deltachat/transport\"\n)\n\nfunc logEvent(bot *deltachat.Bot, accId deltachat.AccountId, event deltachat.Event) {\n\tswitch ev := event.(type) {\n\tcase deltachat.EventInfo:\n\t\tlog.Printf(\"INFO: %v\", ev.Msg)\n\tcase deltachat.EventWarning:\n\t\tlog.Printf(\"WARNING: %v\", ev.Msg)\n\tcase deltachat.EventError:\n\t\tlog.Printf(\"ERROR: %v\", ev.Msg)\n\t}\n}\n\nfunc runEchoBot(bot *deltachat.Bot, accId deltachat.AccountId) {\n\tsysinfo, _ := bot.Rpc.GetSystemInfo()\n\tlog.Println(\"Running deltachat core\", sysinfo[\"deltachat_core_version\"])\n\n\tbot.On(deltachat.EventInfo{}, logEvent)\n\tbot.On(deltachat.EventWarning{}, logEvent)\n\tbot.On(deltachat.EventError{}, logEvent)\n\tbot.OnNewMsg(func(bot *deltachat.Bot, accId deltachat.AccountId, msgId deltachat.MsgId) {\n\t\tmsg, _ := bot.Rpc.GetMessage(accId, msgId)\n\t\tif msg.FromId \u003e deltachat.ContactLastSpecial {\n\t\t\tbot.Rpc.MiscSendTextMessage(accId, msg.ChatId, msg.Text)\n\t\t}\n\t})\n\n\tif isConf, _ := bot.Rpc.IsConfigured(accId); !isConf {\n\t\tlog.Println(\"Bot not configured, configuring...\")\n\t\terr := bot.Configure(accId, os.Args[1], os.Args[2])\n\t\tif err != nil {\n\t\t\tlog.Fatalln(err)\n\t\t}\n\t}\n\n\taddr, _ := bot.Rpc.GetConfig(accId, \"configured_addr\")\n\tlog.Println(\"Listening at:\", addr.Unwrap())\n\tbot.Run()\n}\n\nfunc main() {\n\ttrans := transport.NewIOTransport()\n\ttrans.Open()\n\tdefer trans.Close()\n\trpc := \u0026deltachat.Rpc{Context: context.Background(), Transport: trans}\n\trunEchoBot(deltachat.NewBot(rpc), deltachat.GetAccount(rpc))\n}\n```\n\u003c!-- MARKDOWN-AUTO-DOCS:END --\u003e\n\nSave the previous code snippet as `echobot.go` then run:\n\n```sh\ngo mod init echobot; go mod tidy\ngo run ./echobot.go bot@example.com PASSWORD\n```\n\nCheck the [examples folder](./examples)\nfor more examples.\n\n## Developing bots faster ⚡\n\nIf what you want is to develop bots, you probably should use this library together with\n[deltabot-cli-go](https://github.com/deltachat-bot/deltabot-cli-go/), it takes away the\nrepetitive process of creating the bot CLI and let you focus on writing your message processing logic.\n\n## Testing your code\n\n`deltachat.AcFactory` is provided to help users of this library to unit-test their code.\n\n### Local mail server\n\nYou need to have a local fake email server running. The easiest way to do that is with Docker:\n\n```\n$ docker pull ghcr.io/deltachat/mail-server-tester:release\n$ docker run -it --rm -p 3025:25 -p 3110:110 -p 3143:143 -p 3465:465 -p 3993:993 ghcr.io/deltachat/mail-server-tester\n```\n\n### Using AcFactory\n\nAfter setting up the fake email server, create a file called `main_test.go` inside your tests folder,\nand save it with the following content:\n\n\u003c!-- MARKDOWN-AUTO-DOCS:START (CODE:src=./examples/echobot_full/main_test.go) --\u003e\n\u003c!-- The below code snippet is automatically added from ./examples/echobot_full/main_test.go --\u003e\n```go\npackage main // replace with your package name\n\nimport (\n\t\"testing\"\n\n\t\"github.com/deltachat/deltachat-rpc-client-go/deltachat\"\n)\n\nvar acfactory *deltachat.AcFactory\n\nfunc TestMain(m *testing.M) {\n\tacfactory = \u0026deltachat.AcFactory{}\n\tacfactory.TearUp()\n\tdefer acfactory.TearDown()\n\tm.Run()\n}\n```\n\u003c!-- MARKDOWN-AUTO-DOCS:END --\u003e\n\nNow in your other test files you can do:\n\n\u003c!-- MARKDOWN-AUTO-DOCS:START (CODE:src=./examples/echobot_full/echobot_test.go) --\u003e\n\u003c!-- The below code snippet is automatically added from ./examples/echobot_full/echobot_test.go --\u003e\n```go\npackage main // replace with your package name\n\nimport (\n\t\"testing\"\n\n\t\"github.com/deltachat/deltachat-rpc-client-go/deltachat\"\n\t\"github.com/stretchr/testify/assert\"\n)\n\nfunc TestEchoBot(t *testing.T) {\n\tacfactory.WithOnlineBot(func(bot *deltachat.Bot, botAcc deltachat.AccountId) {\n\t\tgo runEchoBot(bot, botAcc) // this is the function we are testing\n\t\tacfactory.WithOnlineAccount(func(uRpc *deltachat.Rpc, uAccId deltachat.AccountId) {\n\t\t\tchatId := acfactory.CreateChat(uRpc, uAccId, bot.Rpc, botAcc)\n\t\t\tuRpc.MiscSendTextMessage(uAccId, chatId, \"hi\")\n\t\t\tmsg := acfactory.NextMsg(uRpc, uAccId)\n\t\t\tassert.Equal(t, \"hi\", msg.Text) // check that bot echoes back the \"hi\" message from user\n\t\t})\n\t})\n}\n```\n\u003c!-- MARKDOWN-AUTO-DOCS:END --\u003e\n\n### GitHub action\n\nTo run the tests in a GitHub action with the fake mail server service:\n\n\u003c!-- MARKDOWN-AUTO-DOCS:START (CODE:src=./examples/echobot_full/.github/workflows/ci.yml) --\u003e\n\u003c!-- The below code snippet is automatically added from ./examples/echobot_full/.github/workflows/ci.yml --\u003e\n```yml\nname: Test\n\non:\n  push:\n    branches: [ \"master\" ]\n  pull_request:\n    branches: [ \"master\" ]\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n\n      - name: Set up Go\n        uses: actions/setup-go@v3\n        with:\n          go-version: 1.19\n\n      - name: Run tests\n        run: |\n          go test -v\n\n    services:\n      mail_server:\n        image: ghcr.io/deltachat/mail-server-tester:release\n        ports:\n          - 3025:25\n          - 3143:143\n          - 3465:465\n          - 3993:993\n```\n\u003c!-- MARKDOWN-AUTO-DOCS:END --\u003e\n\nCheck the complete example at [examples/echobot_full](./examples/echobot_full)\n\n## Contributing\n\nPull requests are welcome! check [CONTRIBUTING.md](./CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchatmail%2Frpc-client-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchatmail%2Frpc-client-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchatmail%2Frpc-client-go/lists"}