{"id":16659900,"url":"https://github.com/zgtm/dementia","last_synced_at":"2025-04-09T18:42:44.285Z","repository":{"id":57617504,"uuid":"123988185","full_name":"zgtm/dementia","owner":"zgtm","description":"Rust library for the Matrix client-server protocoll","archived":false,"fork":false,"pushed_at":"2018-10-28T22:13:22.000Z","size":33,"stargazers_count":4,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T12:57:11.568Z","etag":null,"topics":["chat","library","matrix","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zgtm.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-05T22:39:50.000Z","updated_at":"2023-10-24T14:15:02.000Z","dependencies_parsed_at":"2022-08-31T18:11:05.337Z","dependency_job_id":null,"html_url":"https://github.com/zgtm/dementia","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/zgtm%2Fdementia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zgtm%2Fdementia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zgtm%2Fdementia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zgtm%2Fdementia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zgtm","download_url":"https://codeload.github.com/zgtm/dementia/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248090324,"owners_count":21046066,"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":["chat","library","matrix","rust"],"created_at":"2024-10-12T10:27:03.105Z","updated_at":"2025-04-09T18:42:44.262Z","avatar_url":"https://github.com/zgtm.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dementia\n\n[![Latest version](https://img.shields.io/crates/v/dementia.svg)](https://crates.io/crates/dementia)\n[![Documentation](https://docs.rs/dementia/badge.svg)](https://docs.rs/dementia)\n![License](https://img.shields.io/crates/l/dementia.svg)\n![Maintenance](https://img.shields.io/badge/maintenance-experimental-blue.svg)\n\nSmall rust library for the [Matrix protocol](https://matrix.org/)\n\n## Status\n\nRight now, only the following are supported:\n\n  * joining rooms\n  * sending text messages and\n  * receiving text messages\n\nSupport for room creation and receiving other kinds of messages are planned for the near time. Also, image upload is on my personal to-do list. :)\n\n## Usage\n\nFirst, add this to your `Cargo.toml`:\n\n```toml\n[dependencies]\ndementia = \"*\"\n```\n\nIn order to connect to a Matrix homeserver and join a room, you need a user on that homeserver and an access token for that user.\n\n```rust\n    let server_url = \"https://matrix.org\"; // The Matrix homeserver\n    let access_token = \"DAx…3wo\";          // The Matrix user access token\n```\n\nWith that, you can create a Homeserver object\n\n```rust\n    let connection = Homeserver::new(server_url)\n        .access_token(access_token)\n        .connect();\n```\n\nor alternatively\n\n```rust\n    let connection = MatrixHomeserver::connect(server_url, access_token);\n```\n\nand use this object to join rooms: \n\n```rust\n    let mut room = connection.join(\"#bottest:https://matrix.org\".to_owned());\n```\n(You need to join a room you want to interact with even if you are already joined. This is for the library to obtain the room id.)\n\nYou receive new messages with `connection.get_new_messages()` (which returns a `Vector\u003cString\u003e` of all messages since last called) and send messages with `connection.send_message()` (which takes a `String`).\n\n\n## Example\n\n```rust\nextern crate dementia;\n\nuse dementia::{Homeserver, Room};\nuse std::{thread, time};\n\nfn main() {\n    let server_url = \"https://matrix.org\"; // The Matrix homeserver\n    let access_token = \"DAx…3wo\";          // The Matrix user access token\n\n    let conn = Homeserver::new(server_url)\n        .access_token(access_token)\n        .connect();\n    // The room must already exist\n    let mut room = conn.join(\"#bottest:https://matrix.org\".to_owned()); \n        \n    let five_sec = time::Duration::new(5, 0);\n    loop {\n        for message in conn.get_new_messages() {\n            if message == \"hi\" {\n                conn.send_message(\"ahoi!\".to_owned());\n            }\n        }\n        thread::sleep(five_sec);\n    }\n}\n```\n\nIf you don't have an access token (yet) but the server supports password authentication, you can let the library generate its own access token:\n\n```rust   \n    let connection = Homeserver::new(\"https://matrix.org\")\n        .username(\"@example:matrix.org\")\n        .password(\"examplepassword\")\n        .login()\n        .connect();\n```\n\nSubsequentlty, you can retrieve the access token for future connections using\n\n```rust\n    access_token = connection.get_access_token();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzgtm%2Fdementia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzgtm%2Fdementia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzgtm%2Fdementia/lists"}