Add /report command

This commit is contained in:
Bohdan Horbeshko 2022-02-26 14:35:43 -05:00
parent b67e29c0bb
commit 4307f85a04

View file

@ -51,6 +51,7 @@ var transportCommands = map[string]command{
"setbio": command{"", "update about"}, "setbio": command{"", "update about"},
"setpassword": command{"[old] [new]", "set or remove password"}, "setpassword": command{"[old] [new]", "set or remove password"},
"config": command{"[param] [value]", "view or update configuration options"}, "config": command{"[param] [value]", "view or update configuration options"},
"report": command{"[chat] [comment]", "report a chat by id or @username"},
} }
var chatCommands = map[string]command{ var chatCommands = map[string]command{
@ -364,6 +365,27 @@ func (c *Client) ProcessTransportCommand(cmdline string, resource string) string
} }
return strings.Join(entries, "\n") return strings.Join(entries, "\n")
case "report":
if len(args) < 2 {
return "Not enough arguments"
}
contact, _, err := c.GetContactByUsername(args[0])
if err != nil {
return err.Error()
}
text := rawCmdArguments(cmdline, 1)
_, err = c.client.ReportChat(&client.ReportChatRequest{
ChatId: contact.Id,
Reason: &client.ChatReportReasonCustom{},
Text: text,
})
if err != nil {
return err.Error()
} else {
return "Reported"
}
case "help": case "help":
return helpString(helpTypeTransport) return helpString(helpTypeTransport)
} }