{"id":13582146,"url":"https://github.com/golift/imessage","last_synced_at":"2025-04-15T03:55:47.153Z","repository":{"id":57511536,"uuid":"166869336","full_name":"golift/imessage","owner":"golift","description":"Go Library used to interact with iMessage (Messages.app) on macOS","archived":false,"fork":false,"pushed_at":"2025-04-04T18:07:37.000Z","size":50,"stargazers_count":44,"open_issues_count":5,"forks_count":6,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-15T03:55:41.279Z","etag":null,"topics":["golang","golang-library","imessage","imessage-bot","imessage-extensions","notifications"],"latest_commit_sha":null,"homepage":"https://golift.io/discord","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/golift.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-01-21T19:35:50.000Z","updated_at":"2025-04-06T12:47:10.000Z","dependencies_parsed_at":"2024-04-25T05:26:48.990Z","dependency_job_id":"20a4dc6f-b589-42bc-8e61-52567d7653c3","html_url":"https://github.com/golift/imessage","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Fimessage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Fimessage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Fimessage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Fimessage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/golift","download_url":"https://codeload.github.com/golift/imessage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249003952,"owners_count":21196794,"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":["golang","golang-library","imessage","imessage-bot","imessage-extensions","notifications"],"created_at":"2024-08-01T15:02:27.331Z","updated_at":"2025-04-15T03:55:47.137Z","avatar_url":"https://github.com/golift.png","language":"Go","readme":"# go-imessage\n\nGo Library used to interact with iMessage (Messages.app) on macOS\n\n[![GoDoc](https://godoc.org/golift.io/imessage?status.svg)](https://godoc.org/golift.io/imessage)\n\nUse this library to send and receive messages using iMessage. I personally use it for\nvarious home automation applications. You can use it to make a chat bot or something\nsimilar. You can bind either a function or a channel to any or all messages.\nThe Send() method uses AppleScript, which is likely going to require some tinkering.\nYou got this far, so I trust you'll figure that out. Let me know how it works out.\n\nThe library uses `fsnotify` to poll for db updates, then checks the database for changes.\nOnly new messages are processed. If somehow `fsnotify` fails it will fall back to polling\nthe database. Pay attention to the debug/error logs. See the example below for an easy\nway to log the library messages.\n\n\nA working example:\n```golang\npackage main\n\nimport (\n\t\"log\"\n\t\"os\"\n\t\"strings\"\n\n\t\"golift.io/imessage\"\n)\n\nfunc checkErr(err error) {\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n}\n\nfunc main() {\n\tiChatDBLocation := \"/Users/\u003cyour username\u003e/Library/Messages/chat.db\"\n\tc := \u0026imessage.Config{\n\t\tSQLPath:   iChatDBLocation, // Set this correctly\n\t\tQueueSize: 10,              // 10-20 is fine. If your server is super busy, tune this.\n\t\tRetries:   3,               // run the applescript up to this many times to send a message. 3 works well.\n\t\tDebugLog:  log.New(os.Stdout, \"[DEBUG] \", log.LstdFlags), // Log debug messages.\n\t\tErrorLog:  log.New(os.Stderr, \"[ERROR] \", log.LstdFlags), // Log errors.\n\t}\n\ts, err := imessage.Init(c)\n\tcheckErr(err)\n\n\tdone := make(chan imessage.Incoming) // Make a channel to receive incoming messages.\n\ts.IncomingChan(\".*\", done)           // Bind to all incoming messages.\n\terr = s.Start()                      // Start outgoing and incoming message go routines.\n\tcheckErr(err)\n\tlog.Print(\"waiting for msgs\")\n\n\tfor msg := range done { // wait here for messages to come in.\n\t\tif len(msg.Text) \u003c 60 {\n\t\t\tlog.Println(\"id:\", msg.RowID, \"from:\", msg.From, \"attachment?\", msg.File, \"msg:\", msg.Text)\n\t\t} else {\n\t\t\tlog.Println(\"id:\", msg.RowID, \"from:\", msg.From, \"length:\", len(msg.Text))\n\t\t}\n\t\tif strings.HasPrefix(msg.Text, \"Help\") {\n\t\t\t// Reply to any incoming message that has the word \"Help\" as the first word.\n\t\t\ts.Send(imessage.Outgoing{Text: \"no help for you\", To: msg.From})\n\t\t}\n\t}\n}\n```\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolift%2Fimessage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgolift%2Fimessage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolift%2Fimessage/lists"}