mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-16 08:52:42 +00:00
Pin co-op invite posts; unpin on lock/cancel
Adds Base.PinEvent / Base.UnpinEvent helpers (m.room.pinned_events state) that read-modify-write the existing pin list — idempotent on both sides. The bot needs power level for state events; failures are logged but not fatal. Schema: add coop_dungeon_runs.invite_post_id to remember which event to unpin. Migration entry included. Wired: - !coop start: pin the invite post in the games room - !coop cancel: unpin before posting cancellation - coopProcessLocks (auto-lock or auto-cancel): unpin before lock/expiry post Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -174,7 +174,11 @@ func (p *AdventurePlugin) handleCoopStart(ctx MessageContext, tierArg string) er
|
||||
|
||||
gr := gamesRoom()
|
||||
if gr != "" {
|
||||
_ = p.SendMessage(gr, renderCoopInvite(run, []CoopMember{{UserID: ctx.Sender, TurnOrder: 0}}, char.DisplayName))
|
||||
postID, err := p.SendMessageID(gr, renderCoopInvite(run, []CoopMember{{UserID: ctx.Sender, TurnOrder: 0}}, char.DisplayName))
|
||||
if err == nil {
|
||||
_ = setCoopRunInvitePostID(run.ID, postID)
|
||||
_ = p.PinEvent(gr, postID)
|
||||
}
|
||||
}
|
||||
return p.SendDM(ctx.Sender, fmt.Sprintf("⚔️ Tier %d co-op invite opened (#%d). Locks in 24h. Recruit your party.", tier, run.ID))
|
||||
}
|
||||
@@ -353,6 +357,9 @@ func (p *AdventurePlugin) handleCoopCancel(ctx MessageContext) error {
|
||||
}
|
||||
gr := gamesRoom()
|
||||
if gr != "" {
|
||||
if run.InvitePostID != "" {
|
||||
_ = p.UnpinEvent(gr, run.InvitePostID)
|
||||
}
|
||||
_ = p.SendMessage(gr, fmt.Sprintf("⚔️ Tier %d Co-op #%d cancelled by the leader.", run.Tier, run.ID))
|
||||
}
|
||||
return p.SendDM(ctx.Sender, fmt.Sprintf("Run #%d cancelled.", run.ID))
|
||||
|
||||
Reference in New Issue
Block a user