### Get Server Statistics using gorocket Source: https://context7.com/badkaktus/gorocket/llms.txt This code example retrieves detailed statistics about the Rocket.Chat server's usage and performance, including user counts, room information, and message volumes. It requires administrator credentials and uses the `gorocket` library. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("admin-user-id"), gorocket.WithXToken("admin-auth-token"), ) response, err := client.Statistics() if err != nil { log.Fatalf("Failed to get statistics: %v", err) } if response.Success { fmt.Printf("=== User Statistics ===\n") fmt.Printf("Total Users: %d\n", response.TotalUsers) fmt.Printf("Active Users: %d\n", response.ActiveUsers) fmt.Printf("Online Users: %d\n", response.OnlineUsers) fmt.Printf("\n=== Room Statistics ===\n") fmt.Printf("Total Rooms: %d\n", response.TotalRooms) fmt.Printf("Total Channels: %d\n", response.TotalChannels) fmt.Printf("Total Private Groups: %d\n", response.TotalPrivateGroups) fmt.Printf("\n=== Message Statistics ===\n") fmt.Printf("Total Messages: %d\n", response.TotalMessages) fmt.Printf("Channel Messages: %d\n", response.TotalChannelMessages) fmt.Printf("Direct Messages: %d\n", response.TotalDirectMessages) } } ``` -------------------------------- ### Get Server Info using gorocket Source: https://context7.com/badkaktus/gorocket/llms.txt This Go snippet shows how to fetch basic information about the Rocket.Chat server, including its version and build details. It uses the `gorocket` library to communicate with the server's information endpoint. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewClient("https://your-rocket-chat.com") response, err := client.Info() if err != nil { log.Fatalf("Failed to get server info: %v", err) } if response.Success { fmt.Printf("Rocket.Chat Version: %s\n", response.Version) fmt.Printf("Build Date: %s\n", response.Info.Build.Date) fmt.Printf("Node Version: %s\n", response.Info.Build.NodeVersion) fmt.Printf("Platform: %s\n", response.Info.Build.Platform) fmt.Printf("Architecture: %s\n", response.Info.Build.Arch) fmt.Printf("Commit Hash: %s\n", response.Info.Commit.Hash) } } ``` -------------------------------- ### Get Group Messages using gorocket Source: https://context7.com/badkaktus/gorocket/llms.txt This example demonstrates how to retrieve messages from a private group. It supports pagination by specifying count and offset parameters. The `gorocket` library parses the message data, including sender and timestamp. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) groupRequest := gorocket.SimpleGroupRequest{ RoomId: "group-room-id-12345", } response, err := client.Count(50).Offset(0).GroupMessages(&groupRequest) if err != nil { log.Fatalf("Failed to get group messages: %v", err) } if response.Success { fmt.Printf("Total messages: %d\n", response.Total) for _, msg := range response.Messages { fmt.Printf("[%s] %s: %s\n", msg.Ts.Format("2006-01-02 15:04:05"), msg.U.Username, msg.Msg) } } } ``` -------------------------------- ### List Private Groups using gorocket Source: https://context7.com/badkaktus/gorocket/llms.txt This code example shows how to retrieve a list of all private groups the authenticated user is a member of. It utilizes the `gorocket` library to make the API call and supports sorting the results. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) sort := map[string]int{"name": 1} response, err := client.Count(25).Sort(sort).GroupList() if err != nil { log.Fatalf("Failed to list groups: %v", err) } if response.Success { fmt.Printf("Total groups: %d\n", response.Total) for _, group := range response.Groups { fmt.Printf("- %s (Messages: %d, Updated: %s)\n", group.Name, group.Msgs, group.UpdatedAt) } } } ``` -------------------------------- ### Get Channel Members using Go Source: https://context7.com/badkaktus/gorocket/llms.txt Lists all members of a specific channel in Rocket.Chat. Requires channel ID and authentication credentials. Returns total member count and member details. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) channelRequest := gorocket.SimpleChannelRequest{ RoomId: "channel-room-id-12345", } response, err := client.ChannelMembers(&channelRequest) if err != nil { log.Fatalf("Failed to get channel members: %v", err) } if response.Success { fmt.Printf("Total members: %d\n", response.Total) for _, member := range response.Members { fmt.Printf("- %s (@%s) - Status: %s\n", member.Name, member.Username, member.Status) } } } ``` -------------------------------- ### Get User Information by Username (Go) Source: https://context7.com/badkaktus/gorocket/llms.txt Retrieves detailed information for a specific user using their username. This function requires an authenticated client and the username of the target user. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("admin-user-id"), gorocket.WithXToken("admin-auth-token"), ) userRequest := gorocket.SimpleUserRequest{ Username: "johndoe", } response, err := client.UsersInfo(&userRequest) if err != nil { log.Fatalf("Failed to get user info: %v", err) } if response.Success { fmt.Printf("User ID: %s\n", response.User.ID) fmt.Printf("Username: %s\n", response.User.Username) fmt.Printf("Name: %s\n", response.User.Name) fmt.Printf("Status: %s\n", response.User.Status) fmt.Printf("Active: %t\n", response.User.Active) } } ``` -------------------------------- ### Get Channel Information in Go Source: https://context7.com/badkaktus/gorocket/llms.txt Retrieves detailed information about a specific channel in Rocket.Chat. Requires client initialization. Accepts a SimpleChannelRequest with the channel name. Returns comprehensive channel details including ID, name, message count, user count, read-only status, and creation timestamp. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) channelRequest := gorocket.SimpleChannelRequest{ RoomName: "engineering-team", } response, err := client.ChannelInfo(&channelRequest) if err != nil { log.Fatalf("Failed to get channel info: %v", err) } if response.Success { fmt.Printf("Channel ID: %s\n", response.Channel.ID) fmt.Printf("Channel Name: %s\n", response.Channel.Name) fmt.Printf("Total Messages: %d\n", response.Channel.Msgs) fmt.Printf("Users Count: %d\n", response.Channel.UsersCount) fmt.Printf("Read Only: %t\n", response.Channel.Ro) fmt.Printf("Created: %s\n", response.Channel.Ts) } } ``` -------------------------------- ### Get Message by ID using Go Source: https://context7.com/badkaktus/gorocket/llms.txt Retrieves a specific message from Rocket.Chat using its unique message ID. Requires the message ID and authentication. Returns message details including sender and content. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) messageRequest := gorocket.SingleMessageId{ MessageId: "message-id-12345", } response, err := client.GetMessage(&messageRequest) if err != nil { log.Fatalf("Failed to get message: %v", err) } if response.Success { fmt.Printf("Message ID: %s\n", response.Message.ID) fmt.Printf("Room ID: %s\n", response.Message.Rid) fmt.Printf("Text: %s\n", response.Message.Msg) fmt.Printf("User: %s\n", response.Message.U.Username) fmt.Printf("Timestamp: %s\n", response.Message.Ts) } } ``` -------------------------------- ### Get Pinned Messages using Go Source: https://context7.com/badkaktus/gorocket/llms.txt Retrieves all pinned messages within a specific Rocket.Chat room. Supports pagination with count and offset parameters. Requires room ID and authentication. Returns a list of pinned messages. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) pinnedRequest := gorocket.GetPinnedMsgRequest{ RoomId: "room-id-12345", Count: 10, Offset: 0, } response, err := client.GetPinnedMessages(&pinnedRequest) if err != nil { log.Fatalf("Failed to get pinned messages: %v", err) } if response.Success { fmt.Printf("Total pinned messages: %d\n", response.Total) for _, msg := range response.Messages { fmt.Printf("\nMessage: %s\n", msg.Msg) fmt.Printf("Pinned by: %s at %s\n", msg.PinnedBy.Username, msg.PinnedAt) } } } ``` -------------------------------- ### Initialize Client with Token and Options (Go) Source: https://context7.com/badkaktus/gorocket/llms.txt Creates a pre-authenticated Rocket.Chat client using a user ID, auth token, and optional timeout. This allows immediate interaction with the API without a separate login step. ```go package main import ( "time" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id-12345"), gorocket.WithXToken("auth-token-abcdef"), gorocket.WithTimeout(30 * time.Second), ) // Client is ready to use with pre-configured authentication me, err := client.Me() if err != nil { panic(err) } println("Authenticated as:", me.Username) } ``` -------------------------------- ### Search Users and Rooms using GoRocket Source: https://context7.com/badkaktus/gorocket/llms.txt Demonstrates how to search for users and rooms matching a query string using the GoRocket client. It initializes a client with authentication details and processes the search results, printing found users and rooms or any errors encountered. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) searchQuery := "engineering" response, err := client.Spotlight(searchQuery) if err != nil { log.Fatalf("Search failed: %v", err) } if response.Success { fmt.Printf("=== Users Found ===\n") for _, user := range response.Users { fmt.Printf("- %s (@%s) - Status: %s\n", user.Name, user.Username, user.Status) } fmt.Printf("\n=== Rooms Found ===\n") for _, room := range response.Rooms { fmt.Printf("- %s (Type: %s)\n", room.Name, room.T) } } else { fmt.Printf("Search error: %s\n", response.Error) } } ``` -------------------------------- ### Create a Rocket Chat client with options in Golang Source: https://github.com/badkaktus/gorocket/blob/master/README.md This code snippet demonstrates how to create a new Rocket Chat client instance using the `NewWithOptions` function from the `gorocket` package. It configures the client with the Rocket Chat server URL, user ID, token, and timeout settings. Requires the `gorocket` and `time` packages. ```go client := gorocket.NewWithOptions("https: ``` -------------------------------- ### Create a user in Rocket Chat using Golang Source: https://github.com/badkaktus/gorocket/blob/master/README.md This code demonstrates how to create a new user in Rocket Chat using the `UsersCreate` function. It defines the user's email, name, password, username, and active status. Error handling is included to catch any creation errors. ```go str := gorocket.NewUser{ Email: "test@email.com", Name: "John Doe", Password: "simplepassword", Username: "johndoe", Active: true, } me, err := client.UsersCreate(&str) if err != nil { fmt.Printf("Error: %+v", err) } fmt.Printf("User was created %t", me.Success) ``` -------------------------------- ### Create New User (Go) Source: https://context7.com/badkaktus/gorocket/llms.txt Creates a new user account in Rocket.Chat with specified details including email, name, password, and roles. Requires an authenticated client with administrative privileges. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("admin-user-id"), gorocket.WithXToken("admin-auth-token"), ) newUser := gorocket.NewUser{ Email: "john.doe@example.com", Name: "John Doe", Password: "securePassword123", Username: "johndoe", Active: true, Roles: []string{"user"}, JoinDefaultChannels: true, RequirePasswordChange: false, SendWelcomeEmail: true, Verified: true, } response, err := client.UsersCreate(&newUser) if err != nil { log.Fatalf("User creation failed: %v", err) } if response.Success { fmt.Printf("User created successfully!\n") fmt.Printf("User ID: %s\n", response.User.ID) fmt.Printf("Username: %s\n", response.User.Username) fmt.Printf("Created at: %s\n", response.User.CreatedAt) } } ``` -------------------------------- ### Create a Rocket Chat client and login in Golang Source: https://github.com/badkaktus/gorocket/blob/master/README.md This code shows how to create a Rocket Chat client and log in using the admin credentials. It uses the `NewClient` and `Login` functions. Error handling is included to check for login failures. ```go client := gorocket.NewClient("https://your-rocket-chat.com") // login as the main admin user login := gorocket.LoginPayload{ User: "admin-login", Password: "admin-password", } lg, err := client.Login(&login) if err != nil{ fmt.Printf("Error: %+v", err) } fmt.Printf("I'm %s", lg.Data.Me.Username) ``` -------------------------------- ### Create a channel and post a message in Rocket Chat using Golang Source: https://github.com/badkaktus/gorocket/blob/master/README.md This code shows how to create a new channel and post a message to it using the `CreateChannel` and `PostMessage` functions from the `gorocket` package. It includes error handling to check for failures during channel creation and message posting. Requires the `gorocket` package. ```go // create a new channel str := gorocket.CreateChannelRequest{ Name: "newchannel", } channel, err := client.CreateChannel(&str) if err != nil { fmt.Printf("Error: %+v", err) } fmt.Printf("Channel was created %t", channel.Success) // post a message str := gorocket.Message{ Channel: "somechannel", Text: "Hey! This is new message from Golang REST Client", } msg, err := client.PostMessage(&str) if err != nil { fmt.Printf("Error: %+v", err) } fmt.Printf("Message was posted %t", msg.Success) ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Invite User to Channel in Go Source: https://context7.com/badkaktus/gorocket/llms.txt Adds a user to an existing channel in Rocket.Chat. Requires client initialization. Accepts an InviteChannelRequest with the channel's Room ID and the user's ID. Returns updated channel information upon successful invitation. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) inviteRequest := gorocket.InviteChannelRequest{ RoomId: "channel-room-id-12345", UserId: "user-id-to-invite", } response, err := client.ChannelInvite(&inviteRequest) if err != nil { log.Fatalf("Failed to invite user: %v", err) } if response.Success { fmt.Printf("User invited successfully!\n") fmt.Printf("Channel: %s\n", response.Channel.Name) fmt.Printf("Updated at: %s\n", response.Channel.UpdatedAt) } } ``` -------------------------------- ### Create Channel in Go Source: https://context7.com/badkaktus/gorocket/llms.txt Creates a new public channel in Rocket.Chat with optional members and settings. Requires client initialization. Accepts a CreateChannelRequest with channel name, members, and read-only status. Returns information about the created channel upon success. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) channelRequest := gorocket.CreateChannelRequest{ Name: "engineering-team", Members: []string{"johndoe", "janedoe"}, ReadOnly: false, } response, err := client.CreateChannel(&channelRequest) if err != nil { log.Fatalf("Channel creation failed: %v", err) } if response.Success { fmt.Printf("Channel created successfully!\n") fmt.Printf("Channel ID: %s\n", response.Channel.ID) fmt.Printf("Channel Name: %s\n", response.Channel.Name) fmt.Printf("Created by: %s\n", response.Channel.U.Username) } } ``` -------------------------------- ### List All Channels in Go Source: https://context7.com/badkaktus/gorocket/llms.txt Retrieves a list of all public channels in Rocket.Chat with support for pagination and sorting. Requires client initialization. Allows specifying count, offset, and sort order. Returns total channel count and a list of channel objects. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) sort := map[string]int{"_updatedAt": -1, "name": 1} response, err := client.Count(50).Offset(0).Sort(sort).ChannelList() if err != nil { log.Fatalf("Failed to list channels: %v", err) } if response.Success { fmt.Printf("Total channels: %d\n", response.Total) fmt.Printf("Showing %d channels:\n", response.Count) for _, channel := range response.Channels { fmt.Printf("- %s (ID: %s, Messages: %d)\n", channel.Name, channel.ID, channel.Msgs) } } } ``` -------------------------------- ### Create Private Group using gorocket Source: https://context7.com/badkaktus/gorocket/llms.txt This snippet demonstrates how to create a new private group (channel) in Rocket.Chat. It requires the group name and a list of initial members. The `gorocket` library handles the API communication. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) groupRequest := gorocket.CreateGroupRequest{ Name: "executive-team", Members: []string{"ceo-username", "cto-username", "cfo-username"}, ReadOnly: false, } response, err := client.CreateGroup(&groupRequest) if err != nil { log.Fatalf("Group creation failed: %v", err) } if response.Success { fmt.Printf("Private group created successfully!\n") fmt.Printf("Group ID: %s\n", response.Group.ID) fmt.Printf("Group Name: %s\n", response.Group.Name) } } ``` -------------------------------- ### Use pagination for endpoint in Golang Source: https://github.com/badkaktus/gorocket/blob/master/README.md This code demonstrates how to use pagination with the `gorocket` client to retrieve data in chunks. It sets the count, offset, and sort order before calling the `ChannelList` function. ```go // sort field in map. 1 - asc, -1 - desc srt := map[string]int{"_updatedAt": 1, "name": -1} client.Count(10).Offset(10).Sort(srt).ChannelList() ``` -------------------------------- ### Authenticate User with Credentials (Go) Source: https://context7.com/badkaktus/gorocket/llms.txt Authenticates a user using their username/email and password. It returns an authentication token and user details. This function requires the Rocket.Chat server URL and login credentials. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewClient("https://your-rocket-chat.com") login := gorocket.LoginPayload{ User: "admin", Password: "adminpassword", } response, err := client.Login(&login) if err != nil { log.Fatalf("Login failed: %v", err) } if response.Status == "success" { fmt.Printf("Logged in as: %s\n", response.Data.Me.Username) fmt.Printf("User ID: %s\n", response.Data.UserID) fmt.Printf("Auth Token: %s\n", response.Data.AuthToken) } } ``` -------------------------------- ### Untitled No description -------------------------------- ### Import gorocket package in Golang Source: https://github.com/badkaktus/gorocket/blob/master/README.md This code snippet shows how to import the gorocket package in a Golang project. The gorocket package provides functionalities to interact with Rocket Chat's REST API. ```go import ( "github.com/badkaktus/gorocket" ) ``` -------------------------------- ### Untitled No description -------------------------------- ### Add Owner to Group using gorocket Source: https://context7.com/badkaktus/gorocket/llms.txt This snippet illustrates how to grant owner privileges to a user within a specific private group. It requires the Room ID of the group and the User ID of the member to be promoted. The `gorocket` library simplifies this permission management task. ```go package main import ( "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) ownerRequest := gorocket.AddGroupPermissionRequest{ RoomId: "group-room-id-12345", UserId: "user-to-make-owner", } response, err := client.AddOwnerGroup(&ownerRequest) if err != nil { log.Fatalf("Failed to add owner: %v", err) } if response.Success { log.Println("User successfully promoted to group owner") } } ``` -------------------------------- ### Post Message to Channel using Go Source: https://context7.com/badkaktus/gorocket/llms.txt Sends a new message to a specified channel in Rocket.Chat. Supports text content and optional attachments with styling. Requires channel name and authentication. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) message := gorocket.Message{ Channel: "engineering-team", Text: "Hello team! This is a message from the Go client.", Attachments: []gorocket.Attachment{ { Title: "Important Update", Text: "Deployment scheduled for tonight", Color: "#00FF00", TitleLink: "https://example.com/deployment", }, }, } response, err := client.PostMessage(&message) if err != nil { log.Fatalf("Failed to post message: %v", err) } if response.Success { fmt.Printf("Message posted successfully!\n") fmt.Printf("Message ID: %s\n", response.Message.ID) fmt.Printf("Channel: %s\n", response.Channel) fmt.Printf("Timestamp: %s\n", response.Message.Ts) } else { fmt.Printf("Error: %s (%s)\n", response.Error, response.ErrorType) } } ``` -------------------------------- ### Update User Details in Go Source: https://context7.com/badkaktus/gorocket/llms.txt Updates an existing user's information in Rocket.Chat, including name, email, password, and roles. Requires client initialization with server URL, user ID, and authentication token. Accepts a UserUpdateRequest object and returns a UserUpdateResponse. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("admin-user-id"), gorocket.WithXToken("admin-auth-token"), ) updateRequest := gorocket.UserUpdateRequest{ UserId: "user-id-to-update", Data: gorocket.UserUpdateData{ Name: "John Updated Doe", Email: "john.updated@example.com", Active: true, Roles: []string{"user", "moderator"}, Verified: true, }, } response, err := client.UsersUpdate(&updateRequest) if err != nil { log.Fatalf("User update failed: %v", err) } if response.Success { fmt.Printf("User updated successfully!\n") fmt.Printf("Username: %s\n", response.User.Username) fmt.Printf("Email: %s\n", response.User.Emails[0].Address) fmt.Printf("Updated at: %s\n", response.User.UpdatedAt) } } ``` -------------------------------- ### Pin Message using Go Source: https://context7.com/badkaktus/gorocket/llms.txt Pins a specific message to the top of a Rocket.Chat channel. Requires the message ID and authentication. Returns confirmation and details of the pinned message. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) pinRequest := gorocket.SingleMessageId{ MessageId: "message-id-to-pin", } response, err := client.PinMessage(&pinRequest) if err != nil { log.Fatalf("Failed to pin message: %v", err) } if response.Success { fmt.Printf("Message pinned successfully!\n") fmt.Printf("Message ID: %s\n", response.Message.ID) fmt.Printf("Pinned by: %s\n", response.Message.U.Username) } } ``` -------------------------------- ### Delete User Account in Go Source: https://context7.com/badkaktus/gorocket/llms.txt Removes a user from the Rocket.Chat server permanently. Requires client initialization with server URL, user ID, and authentication token. Accepts a UsersDelete struct with the username to be deleted and returns a success status. ```go package main import ( "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("admin-user-id"), gorocket.WithXToken("admin-auth-token"), ) deleteRequest := gorocket.UsersDelete{ Username: "johndoe", } response, err := client.UsersDelete(&deleteRequest) if err != nil { log.Fatalf("User deletion failed: %v", err) } if response.Success { log.Println("User deleted successfully") } } ``` -------------------------------- ### Logout User Session (Go) Source: https://context7.com/badkaktus/gorocket/llms.txt Terminates the current user session and invalidates the authentication token. This function requires an initialized client with valid authentication credentials. ```go package main import ( "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id-12345"), gorocket.WithXToken("auth-token-abcdef"), ) response, err := client.Logout() if err != nil { log.Fatalf("Logout failed: %v", err) } if response.Status == "success" { log.Println("Successfully logged out:", response.Data.Message) } } ``` -------------------------------- ### Delete Message using Go Source: https://context7.com/badkaktus/gorocket/llms.txt Removes a specific message from a Rocket.Chat room. Requires the room ID, message ID, and an option to delete as the authenticated user. Returns confirmation of deletion. ```go package main import ( "fmt" "log" "github.com/badkaktus/gorocket" ) func main() { client := gorocket.NewWithOptions("https://your-rocket-chat.com", gorocket.WithUserID("user-id"), gorocket.WithXToken("auth-token"), ) deleteRequest := gorocket.DeleteMessageRequest{ RoomID: "room-id-12345", MsgID: "message-id-to-delete", AsUser: true, } response, err := client.DeleteMessage(&deleteRequest) if err != nil { log.Fatalf("Failed to delete message: %v", err) } if response.Success { fmt.Printf("Message deleted successfully!\n") fmt.Printf("Deleted message ID: %s\n", response.ID) } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.