Skip to content

[IMSERVER-20667] add methods for threads and chats #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ type Bot struct {
Info *BotInfo
}

// AutosubscribeToThreads toggles thread auto-subscription behaviour for the specified chat.
// enable – turn the feature on/off.
// withExisting – if true, the bot will also subscribe to already existing threads.
func (b *Bot) AutosubscribeToThreads(chatID string, enable, withExisting bool) error {
return b.client.AutosubscribeToThreads(chatID, enable, withExisting)
}

// AddThread adds a new thread to the specified chat and returns the thread ID.
func (b *Bot) AddThread(chatID, msgID string) (*Thread, error) {
return b.client.AddThread(chatID, msgID)
}

// GetThreadSubscribers gets the subscribers list for a thread.
// Either cursor or pageSize must be provided.
func (b *Bot) GetThreadSubscribers(threadID string, cursor string, pageSize int) (*ThreadSubscribers, error) {
return b.client.GetThreadSubscribers(threadID, cursor, pageSize)
}

// GetInfo returns information about bot:
// id, name, about, avatar
func (b *Bot) GetInfo() (*BotInfo, error) {
Expand Down Expand Up @@ -80,7 +98,17 @@ func (b *Bot) UnblockChatUser(chatID, userID string) error {
return b.client.UnblockChatUser(chatID, userID)
}

// ResolveChatJoinRequests sends a decision to accept/decline user join to chat
// DeleteChatMembers removes multiple members from chat
func (b *Bot) DeleteChatMembers(chatID string, members []string) error {
return b.client.DeleteChatMembers(chatID, members)
}

// AddChatMembers adds multiple members to chat
func (b *Bot) AddChatMembers(chatID string, members []string) error {
return b.client.AddChatMembers(chatID, members)
}

// ResolveChatJoinRequests resolves pending join requests for specified user or all pending users
func (b *Bot) ResolveChatJoinRequests(chatID, userID string, accept, everyone bool) error {
return b.client.ResolveChatPending(chatID, userID, accept, everyone)
}
Expand Down
4 changes: 2 additions & 2 deletions button_easyjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ func (c *Chat) GetPendingUsers() ([]User, error) {
return c.client.GetChatPendingUsers(c.ID)
}

// DeleteMembers removes members from chat
func (c *Chat) DeleteMembers(members []string) error {
return c.client.DeleteChatMembers(c.ID, members)
}

// AddMembers adds members to chat
func (c *Chat) AddMembers(members []string) error {
return c.client.AddChatMembers(c.ID, members)
}

// Block user and remove him from chat.
// If deleteLastMessages is true, the messages written recently will be deleted
func (c *Chat) BlockUser(userID string, deleteLastMessages bool) error {
Expand Down Expand Up @@ -129,3 +139,13 @@ func (c *Chat) SetAbout(about string) error {
func (c *Chat) SetRules(rules string) error {
return c.client.SetChatRules(c.ID, rules)
}

// AddThread adds a new thread to the specified chat and returns the thread ID
func (c *Chat) AddThread(msgID string) (*Thread, error) {
return c.client.AddThread(c.ID, msgID)
}

// AutosubscribeToThreads toggles thread auto-subscription for the chat
func (c *Chat) AutosubscribeToThreads(enable, withExisting bool) error {
return c.client.AutosubscribeToThreads(c.ID, enable, withExisting)
}
2 changes: 1 addition & 1 deletion chat_easyjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading