Add /report command

calls
Bohdan Horbeshko 2 years ago
parent b67e29c0bb
commit 4307f85a04

@ -51,6 +51,7 @@ var transportCommands = map[string]command{
"setbio": command{"", "update about"},
"setpassword": command{"[old] [new]", "set or remove password"},
"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{
@ -364,6 +365,27 @@ func (c *Client) ProcessTransportCommand(cmdline string, resource string) string
}
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":
return helpString(helpTypeTransport)
}

Loading…
Cancel
Save