mirror of
https://codeberg.org/june64/mrvc.git
synced 2026-01-10 16:06:33 +01:00
show room id for each room in output and list given aliases separately
This commit is contained in:
parent
9441eef002
commit
a566209a36
1 changed files with 22 additions and 6 deletions
28
main.go
28
main.go
|
|
@ -73,7 +73,8 @@ func main() {
|
|||
fclient.WithTimeout(config.HomeserverVersionInfoTimeout),
|
||||
)
|
||||
|
||||
givenRoomsByRoomID := make(map[id.RoomID]string)
|
||||
roomIDSet := make(map[id.RoomID]bool)
|
||||
aliasSetByRoomID := make(map[id.RoomID](map[string]bool))
|
||||
for _, room := range config.Rooms {
|
||||
// Check, if given room is an alias and try to resolve it into a room id.
|
||||
if strings.HasPrefix(room, "#") {
|
||||
|
|
@ -81,14 +82,22 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
givenRoomsByRoomID[resolvedAlias.RoomID] = room
|
||||
|
||||
roomIDSet[resolvedAlias.RoomID] = true
|
||||
|
||||
aliasSet, ok := aliasSetByRoomID[resolvedAlias.RoomID]
|
||||
if !ok {
|
||||
aliasSet = make(map[string]bool)
|
||||
aliasSetByRoomID[resolvedAlias.RoomID] = aliasSet
|
||||
}
|
||||
aliasSet[room] = true
|
||||
} else {
|
||||
givenRoomsByRoomID[id.RoomID(room)] = room
|
||||
roomIDSet[id.RoomID(room)] = true
|
||||
}
|
||||
}
|
||||
|
||||
roomIDs := make([]id.RoomID, 0, len(givenRoomsByRoomID))
|
||||
for roomID := range givenRoomsByRoomID {
|
||||
roomIDs := make([]id.RoomID, 0, len(roomIDSet))
|
||||
for roomID := range roomIDSet {
|
||||
roomIDs = append(roomIDs, roomID)
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +105,14 @@ func main() {
|
|||
|
||||
for roomID, roomInfo := range roomInfoTree {
|
||||
fmt.Println("Room:")
|
||||
fmt.Printf(" %s -> %d\n", givenRoomsByRoomID[roomID], roomInfo.MemberCount)
|
||||
fmt.Printf(" %s -> %d\n", roomID, roomInfo.MemberCount)
|
||||
aliasSet, ok := aliasSetByRoomID[roomID]
|
||||
if ok {
|
||||
fmt.Println("Given Aliases:")
|
||||
for alias := range aliasSet {
|
||||
fmt.Printf(" %s\n", alias)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Version Support:")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue