Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ananace/ruby-matrix-sdk
Ruby SDK for the Matrix communication protocol
https://github.com/ananace/ruby-matrix-sdk
matrix-protocol ruby
Last synced: 5 days ago
JSON representation
Ruby SDK for the Matrix communication protocol
- Host: GitHub
- URL: https://github.com/ananace/ruby-matrix-sdk
- Owner: ananace
- License: mit
- Created: 2018-05-04T17:46:13.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-24T07:14:00.000Z (4 months ago)
- Last Synced: 2025-01-20T10:05:30.216Z (5 days ago)
- Topics: matrix-protocol, ruby
- Language: Ruby
- Size: 952 KB
- Stars: 82
- Watchers: 7
- Forks: 10
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-matrix-bots - Ruby Matrix SDK (ananace)
README
# Ruby Matrix SDK
A Ruby gem for easing the development of software that communicates with servers implementing the Matrix protocol.
There is a Matrix room for the discussion about usage and development at [#ruby-matrix-sdk:kittenface.studio](https://matrix.to/#/#ruby-matrix-sdk:kittenface.studio).
Live YARD documentation can be found at; https://ruby-sdk.ananace.dev
## Example usage
For more fully-featured examples, check the [examples](examples/) folder.
```ruby
# Raw API usage
require 'matrix_sdk'api = MatrixSdk::Api.new 'https://matrix.org'
api.login user: 'example', password: 'notarealpass'
api.whoami?
# => {:user_id=>"@example:matrix.org"}# It's possible to call arbitrary APIs as well
api.request :get, :federation_v1, '/version'
# => {:server=>{:version=>"0.28.1", :name=>"Synapse"}}
``````ruby
# Client wrapper with login
require 'matrix_sdk'client = MatrixSdk::Client.new 'https://example.com'
client.login 'username', 'notarealpass' #, no_sync: trueclient.rooms.count
# => 5
hq = client.find_room '#matrix:matrix.org'
# => #
hq.guest_access?
# => true
hq.send_text "This is an example message - don't actually do this ;)"
# => {:event_id=>"$123457890abcdef:matrix.org"}
``````ruby
# Client wrapper with token
require 'matrix_sdk'client = MatrixSdk::Client.new 'https://example.com'
client.api.access_token = 'thisisnotarealtoken'# Doesn't automatically trigger a sync when setting the token directly
client.rooms.count
# => 0client.sync
client.rooms.count
# => 5
``````ruby
#!/bin/env ruby
# Bot DSL
require 'matrix_sdk/bot'command :plug do
room.send_text <<~PLUG
The Ruby SDK is a fine method for writing applications communicating over the Matrix protocol.
It can easily be integrated with Rails, and it supports most client/bot use-cases.
PLUG
end
```## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/ananace/ruby-matrix-sdk
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).