@@ -3,18 +3,22 @@ package connector
33import (
44 "context"
55 "encoding/json"
6+ "fmt"
67 "io"
78 "math/rand"
89 "net/http"
910 "strconv"
1011 "strings"
1112 "time"
1213
14+ "maunium.net/go/mautrix/bridge/status"
1315 "maunium.net/go/mautrix/bridgev2/commands"
1416 "maunium.net/go/mautrix/event"
17+ "maunium.net/go/mautrix/id"
1518)
1619
1720var AllCommands = []commands.CommandHandler {
21+ SendStateCommand ,
1822 NewRoomCommand ,
1923 GhostsCommand ,
2024 MessagesCommand ,
@@ -28,6 +32,42 @@ var DummyHelpsection = commands.HelpSection{
2832 Order : 99 ,
2933}
3034
35+ var SendStateCommand = & commands.FullHandler {
36+ Func : func (e * commands.Event ) {
37+ if len (e .Args ) == 0 {
38+ e .Reply ("Missing state argument" )
39+ return
40+ }
41+
42+ stateEvent := status .BridgeStateEvent (e .Args [0 ])
43+ state := status.BridgeState {
44+ StateEvent : stateEvent ,
45+ RemoteID : "*" ,
46+ }
47+
48+ for userID , perm := range e .Bridge .Config .Permissions {
49+ if ! perm .Admin {
50+ continue
51+ }
52+ user , err := e .Bridge .GetUserByMXID (context .Background (), id .UserID (userID ))
53+ if err != nil {
54+ e .Reply (fmt .Sprintf ("Error getting user: %s" , err .Error ()))
55+ return
56+ }
57+ user .GetDefaultLogin ().BridgeState .Send (state )
58+ }
59+
60+ e .Reply ("Generated states" )
61+ },
62+ Name : "send-state" ,
63+ Help : commands.HelpMeta {
64+ Description : "Send bridge states" ,
65+ Args : "[sevent]" ,
66+ Section : DummyHelpsection ,
67+ },
68+ RequiresLogin : true ,
69+ }
70+
3171var NewRoomCommand = & commands.FullHandler {
3272 Func : func (e * commands.Event ) {
3373 login := e .User .GetDefaultLogin ()
0 commit comments