Merge branch 'main' into 'user-whitelisting'
# Conflicts: # bot/bot.go
This commit is contained in:
30
bot/bot.go
30
bot/bot.go
@@ -24,20 +24,22 @@ type Bot struct {
|
||||
rooms sync.Map
|
||||
log *logger.Logger
|
||||
lp *linkpearl.Linkpearl
|
||||
mu map[id.RoomID]*sync.Mutex
|
||||
handledMembershipEvents sync.Map
|
||||
}
|
||||
|
||||
// New creates a new matrix bot
|
||||
func New(lp *linkpearl.Linkpearl, log *logger.Logger, prefix, domain string, noowner, federation bool, allowedUsers []*regexp.Regexp) *Bot {
|
||||
return &Bot{
|
||||
noowner: noowner,
|
||||
federation: federation,
|
||||
prefix: prefix,
|
||||
domain: domain,
|
||||
noowner: noowner,
|
||||
federation: federation,
|
||||
prefix: prefix,
|
||||
domain: domain,
|
||||
allowedUsers: allowedUsers,
|
||||
rooms: sync.Map{},
|
||||
log: log,
|
||||
lp: lp,
|
||||
rooms: sync.Map{},
|
||||
log: log,
|
||||
lp: lp,
|
||||
mu: map[id.RoomID]*sync.Mutex{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,20 +81,6 @@ func (b *Bot) Start(statusMsg string) error {
|
||||
return b.lp.Start(statusMsg)
|
||||
}
|
||||
|
||||
// GetMappings returns mapping of mailbox = room
|
||||
func (b *Bot) GetMapping(mailbox string) (id.RoomID, bool) {
|
||||
v, ok := b.rooms.Load(mailbox)
|
||||
if !ok {
|
||||
return "", ok
|
||||
}
|
||||
roomID, ok := v.(id.RoomID)
|
||||
if !ok {
|
||||
return "", ok
|
||||
}
|
||||
|
||||
return roomID, ok
|
||||
}
|
||||
|
||||
// Stop the bot
|
||||
func (b *Bot) Stop() {
|
||||
err := b.lp.GetClient().SetPresence(event.PresenceOffline)
|
||||
|
||||
Reference in New Issue
Block a user