Skip to content

rdbo/simplex-chat-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simplex-chat-ruby

A port for the SimpleX Chat client API for Ruby

License

This project is licensed under the GNU AGPL-3.0 (no later versions).

Read LICENSE for more information.

Showcase

showcase

Usage

  1. Install the Gem from RubyGems

    gem install simplex-chat
  2. Start your local simplex-chat client on port 5225 (or any port you wish)

    simplex-chat -p 5225
  3. Connect the SimpleXChat::ClientAgent to your local client

    require 'simplex-chat'
    require 'net/http'
    
    client = SimpleXChat::ClientAgent.new URI('ws://localhost:5225')
  4. Now the client is connected and you can start using the APIs

    # Get version
    version = client.api_version
    puts "SimpleX Chat version: #{version}"
    
    # Listen to incoming client messages
    loop do
      chat_msg = client.next_chat_message
      break if chat_msg == nil
    
      # Reply if user sends '/say_hello'
      if chat_msg[:msg_text] == "/say_hello"
        client.api_send_text_message chat_msg[:chat_type], chat_msg[:sender], "Hello! This was sent automagically"
      end
    end
    
    # Much more... Read the examples for more information

About

Ruby API for SimpleX Chat

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages