Skip to content
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

Add sleep between calls to add user to channels #124

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion server/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ type ConfigMessage struct {

// Configuration from config.json
type Configuration struct {
WelcomeMessages []*ConfigMessage
WelcomeMessages []*ConfigMessage
AddToChannelDelayInMilliseconds int
}

// List of the welcome messages from the configuration
Expand All @@ -63,6 +64,8 @@ func (p *Plugin) OnConfigurationChange() error {
return err
}

p.conf = c

p.welcomeMessages.Store(c.WelcomeMessages)

return nil
Expand Down
2 changes: 2 additions & 0 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type Plugin struct {

welcomeMessages atomic.Value

conf Configuration

// botUserID of the created bot account.
botUserID string
}
Expand Down
2 changes: 2 additions & 0 deletions server/welcomebot.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ func (p *Plugin) joinChannel(action *Action, channelName string) {
p.API.LogError("Couldn't add user to the channel, continuing to next channel", "user_id", action.Context.UserID, "channel_id", channel.Id)
return
}

time.Sleep(time.Millisecond * time.Duration(p.conf.AddToChannelDelayInMilliseconds))
} else {
p.API.LogError("failed to get channel, continuing to the next channel", "channel_name", channelName, "user_id", action.Context.UserID)
}
Expand Down