resync rooms every 5 minutes
This commit is contained in:
@@ -45,6 +45,7 @@ func (m *Manager) GetBot() Bot {
|
||||
}
|
||||
if config == nil {
|
||||
config = make(Bot, 0)
|
||||
return config
|
||||
}
|
||||
m.ble = config.BanlistEnabled()
|
||||
|
||||
@@ -86,6 +87,7 @@ func (m *Manager) GetBanlist() List {
|
||||
}
|
||||
if config == nil {
|
||||
config = make(List, 0)
|
||||
return config
|
||||
}
|
||||
m.bl = config
|
||||
return config
|
||||
@@ -115,6 +117,7 @@ func (m *Manager) GetGreylist() List {
|
||||
}
|
||||
if config == nil {
|
||||
config = make(List, 0)
|
||||
return config
|
||||
}
|
||||
|
||||
return config
|
||||
|
||||
12
bot/data.go
12
bot/data.go
@@ -38,9 +38,11 @@ func (b *Bot) migrate() error {
|
||||
}
|
||||
|
||||
func (b *Bot) syncRooms() error {
|
||||
adminRooms := []id.RoomID{}
|
||||
|
||||
adminRoom := b.cfg.GetBot().AdminRoom()
|
||||
if adminRoom != "" {
|
||||
b.adminRooms = append(b.adminRooms, adminRoom)
|
||||
adminRooms = append(adminRooms, adminRoom)
|
||||
}
|
||||
|
||||
resp, err := b.lp.GetClient().JoinedRooms()
|
||||
@@ -60,9 +62,10 @@ func (b *Bot) syncRooms() error {
|
||||
}
|
||||
|
||||
if cfg.Owner() != "" && b.allowAdmin(id.UserID(cfg.Owner()), "") {
|
||||
b.adminRooms = append(b.adminRooms, roomID)
|
||||
adminRooms = append(adminRooms, roomID)
|
||||
}
|
||||
}
|
||||
b.adminRooms = adminRooms
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -101,3 +104,8 @@ func (b *Bot) initBotUsers() ([]string, error) {
|
||||
cfg.Set(config.BotUsers, "@*:"+homeserver)
|
||||
return cfg.Users(), b.cfg.SetBot(cfg)
|
||||
}
|
||||
|
||||
// SyncRooms and mailboxes
|
||||
func (b *Bot) SyncRooms() {
|
||||
b.syncRooms() //nolint:errcheck // nothing can be done here
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user