|
|
@ -59,6 +59,7 @@ var chatCommands = map[string]command{
|
|
|
|
"s": command{"edited message", "edit your last message"},
|
|
|
|
"s": command{"edited message", "edit your last message"},
|
|
|
|
"silent": command{"message", "send a message without sound"},
|
|
|
|
"silent": command{"message", "send a message without sound"},
|
|
|
|
"schedule": command{"{online | 2006-01-02T15:04:05 | 15:04:05} message", "schedules a message either to timestamp or to whenever the user goes online"},
|
|
|
|
"schedule": command{"{online | 2006-01-02T15:04:05 | 15:04:05} message", "schedules a message either to timestamp or to whenever the user goes online"},
|
|
|
|
|
|
|
|
"forward": command{"message_id target_chat", "forwards a message"},
|
|
|
|
"add": command{"@username", "add @username to your chat list"},
|
|
|
|
"add": command{"@username", "add @username to your chat list"},
|
|
|
|
"join": command{"https://t.me/invite_link", "join to chat via invite link"},
|
|
|
|
"join": command{"https://t.me/invite_link", "join to chat via invite link"},
|
|
|
|
"group": command{"title", "create groupchat «title» with current user"},
|
|
|
|
"group": command{"title", "create groupchat «title» with current user"},
|
|
|
@ -575,6 +576,36 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return "Message processing error", true
|
|
|
|
return "Message processing error", true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// forward a message to chat
|
|
|
|
|
|
|
|
case "forward":
|
|
|
|
|
|
|
|
if len(args) < 2 {
|
|
|
|
|
|
|
|
return notEnoughArguments, true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageId, err := strconv.ParseInt(args[0], 10, 64)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return "Cannot parse message ID", true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
targetChatParts := strings.Split(args[1], "@") // full JIDs are supported too
|
|
|
|
|
|
|
|
targetChatId, err := strconv.ParseInt(targetChatParts[0], 10, 64)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return "Cannot parse target chat ID", true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messages, err := c.client.ForwardMessages(&client.ForwardMessagesRequest{
|
|
|
|
|
|
|
|
ChatId: targetChatId,
|
|
|
|
|
|
|
|
FromChatId: chatID,
|
|
|
|
|
|
|
|
MessageIds: []int64{messageId},
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err.Error(), true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if messages != nil && messages.Messages != nil {
|
|
|
|
|
|
|
|
for _, message := range messages.Messages {
|
|
|
|
|
|
|
|
c.ProcessIncomingMessage(targetChatId, message)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// add @contact
|
|
|
|
// add @contact
|
|
|
|
case "add":
|
|
|
|
case "add":
|
|
|
|
if len(args) < 1 {
|
|
|
|
if len(args) < 1 {
|
|
|
|