Channels are RocketChat's public rooms.
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
channel = session.channels.create('new_channelname', members: ['username1', 'username2'])
Optional parameters for create are:
:members, :read_only, :custom_fields, :extra_data
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
channel = session.channels.info(name: 'some_channelname')
Either room_id (RocketChat's ID) or name can be used.
To delete a channel, the same options as an info request can be used (room_id
or name
).
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
success = session.channels.add_all(room_id: 'ByehQjC44FwMeiLbX')
Optional parameter for add_all is active_users_only
(default false)
N.B. the addAll API endpoint requires the calling user to have the admin
role
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
success = session.channels.add_owner(name: 'some_channelname', username: 'some_username')
Either room_id (RocketChat's ID) or name can be used. The same applies to user_id and username.
To remove an owner from a channel, the same options as an add_owner
request can be used.
To add a moderator to a channel, the same options as an add_owner
request can be used.
To remove a moderator from a channel, the same options as an add_owner
request can be used.
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
channel = session.channels.invite(name: 'some_channel_name', username: 'some_username')
Either room_id (RocketChat's ID) or name can be used. The same applies to user_id and username.
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
channel = session.channels.join(name: 'some_channel_name')
Either room_id (RocketChat's ID) or name can be used.
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
channel = session.channels.leave(name: 'some_channel_name')
Either room_id (RocketChat's ID) or name can be used.
N.B. list is also used for searching/querying
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
channels = session.channels.list(query: { usernames: 'friend-username' })
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
channel = session.channels.info(name: 'some_channel_name')
session.channels.rename(channel.id, 'new_channel_name')
This method executes all setSomethingOrOther calls.
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
session.channels.set_attr(name: 'some_channel_name', topic: 'Chatting about stuff')
This method returns all online users in a channel.
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
session.channels.online(name: 'some_channel_name')
This method returns all members in a channel.
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
session.channels.members(name: 'some_channel_name')
Upload file to the room
require 'rocketchat'
rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
session.channels.upload_file(room_id: 'GENERAL', file: File, filename: "Optional. The name of the file to use.", content_type: "Optional. The content type of the uploaded file", msg: "Optional Message", description: "Optional Description", tmid: "Optional thread message id")