diff --git a/telegram/commands.go b/telegram/commands.go index d7318d0..f523f39 100644 --- a/telegram/commands.go +++ b/telegram/commands.go @@ -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) }