mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-13 09:03:10 +01:00
Add missing commands to help
This commit is contained in:
parent
2353924456
commit
ba4aaa8f52
1 changed files with 22 additions and 7 deletions
29
commands.go
29
commands.go
|
@ -170,10 +170,12 @@ func (handler *CommandHandler) CommandRelaybot(ce *CommandEvent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (handler *CommandHandler) CommandDevTest(ce *CommandEvent) {
|
func (handler *CommandHandler) CommandDevTest(_ *CommandEvent) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cmdSetPowerLevelHelp = `set-pl [user ID] <power level> - Change the power level in a portal room. Only for bridge admins.`
|
||||||
|
|
||||||
func (handler *CommandHandler) CommandSetPowerLevel(ce *CommandEvent) {
|
func (handler *CommandHandler) CommandSetPowerLevel(ce *CommandEvent) {
|
||||||
portal := ce.Bridge.GetPortalByMXID(ce.RoomID)
|
portal := ce.Bridge.GetPortalByMXID(ce.RoomID)
|
||||||
if portal == nil {
|
if portal == nil {
|
||||||
|
@ -348,6 +350,8 @@ func (handler *CommandHandler) CommandReconnect(ce *CommandEvent) {
|
||||||
ce.User.PostLogin()
|
ce.User.PostLogin()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cmdDeleteConnectionHelp = `delete-connection - Disconnect ignoring errors and delete internal connection state.`
|
||||||
|
|
||||||
func (handler *CommandHandler) CommandDeleteConnection(ce *CommandEvent) {
|
func (handler *CommandHandler) CommandDeleteConnection(ce *CommandEvent) {
|
||||||
if ce.User.Conn == nil {
|
if ce.User.Conn == nil {
|
||||||
ce.Reply("You don't have a WhatsApp connection.")
|
ce.Reply("You don't have a WhatsApp connection.")
|
||||||
|
@ -427,6 +431,7 @@ func (handler *CommandHandler) CommandHelp(ce *CommandEvent) {
|
||||||
cmdPrefix + cmdDeleteSessionHelp,
|
cmdPrefix + cmdDeleteSessionHelp,
|
||||||
cmdPrefix + cmdReconnectHelp,
|
cmdPrefix + cmdReconnectHelp,
|
||||||
cmdPrefix + cmdDisconnectHelp,
|
cmdPrefix + cmdDisconnectHelp,
|
||||||
|
cmdPrefix + cmdDeleteConnectionHelp,
|
||||||
cmdPrefix + cmdPingHelp,
|
cmdPrefix + cmdPingHelp,
|
||||||
cmdPrefix + cmdLoginMatrixHelp,
|
cmdPrefix + cmdLoginMatrixHelp,
|
||||||
cmdPrefix + cmdLogoutMatrixHelp,
|
cmdPrefix + cmdLogoutMatrixHelp,
|
||||||
|
@ -434,6 +439,9 @@ func (handler *CommandHandler) CommandHelp(ce *CommandEvent) {
|
||||||
cmdPrefix + cmdListHelp,
|
cmdPrefix + cmdListHelp,
|
||||||
cmdPrefix + cmdOpenHelp,
|
cmdPrefix + cmdOpenHelp,
|
||||||
cmdPrefix + cmdPMHelp,
|
cmdPrefix + cmdPMHelp,
|
||||||
|
cmdPrefix + cmdSetPowerLevelHelp,
|
||||||
|
cmdPrefix + cmdDeletePortalHelp,
|
||||||
|
cmdPrefix + cmdDeleteAllPortalsHelp,
|
||||||
}, "\n* "))
|
}, "\n* "))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,23 +476,30 @@ func (handler *CommandHandler) CommandSync(ce *CommandEvent) {
|
||||||
ce.Reply("Sync complete.")
|
ce.Reply("Sync complete.")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (handler *CommandHandler) CommandDeletePortal(ce *CommandEvent) {
|
const cmdDeletePortalHelp = `delete-portal - Delete the current portal. If the portal is used by other people, this is limited to bridge admins.`
|
||||||
if !ce.User.Admin {
|
|
||||||
ce.Reply("Only bridge admins can delete portals")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
func (handler *CommandHandler) CommandDeletePortal(ce *CommandEvent) {
|
||||||
portal := ce.Bridge.GetPortalByMXID(ce.RoomID)
|
portal := ce.Bridge.GetPortalByMXID(ce.RoomID)
|
||||||
if portal == nil {
|
if portal == nil {
|
||||||
ce.Reply("You must be in a portal room to use that command")
|
ce.Reply("You must be in a portal room to use that command")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !ce.User.Admin {
|
||||||
|
users := portal.GetUserIDs()
|
||||||
|
if len(users) > 1 || (len(users) == 1 && users[0] != ce.User.MXID) {
|
||||||
|
ce.Reply("Only bridge admins can delete portals with other Matrix users")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
portal.log.Infoln(ce.User.MXID, "requested deletion of portal.")
|
portal.log.Infoln(ce.User.MXID, "requested deletion of portal.")
|
||||||
portal.Delete()
|
portal.Delete()
|
||||||
portal.Cleanup(false)
|
portal.Cleanup(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cmdDeleteAllPortalsHelp = `delete-all-portals - Delete all your portals that aren't used by any other user.'`
|
||||||
|
|
||||||
func (handler *CommandHandler) CommandDeleteAllPortals(ce *CommandEvent) {
|
func (handler *CommandHandler) CommandDeleteAllPortals(ce *CommandEvent) {
|
||||||
portals := ce.User.GetPortals()
|
portals := ce.User.GetPortals()
|
||||||
portalsToDelete := make([]*Portal, 0, len(portals))
|
portalsToDelete := make([]*Portal, 0, len(portals))
|
||||||
|
@ -528,7 +543,7 @@ func (handler *CommandHandler) CommandDeleteAllPortals(ce *CommandEvent) {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
const cmdListHelp = `list - Get a list of all contacts and groups.`
|
const cmdListHelp = `list <contacts|groups> [page] [items per page] - Get a list of all contacts and groups.`
|
||||||
|
|
||||||
func formatContacts(contacts bool, skip, max int, input map[string]whatsapp.Contact) (result []string, total int) {
|
func formatContacts(contacts bool, skip, max int, input map[string]whatsapp.Contact) (result []string, total int) {
|
||||||
skipped := 0
|
skipped := 0
|
||||||
|
|
Loading…
Reference in a new issue