FileIDstring`json:"file_id"`// FileID is the identifier for this file, which can be used to download or reuse the file
FileUniqueIDstring`json:"file_unique_id"`// FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
Widthint`json:"width"`// Width video width as defined by sender
Heightint`json:"height"`// Height video height as defined by sender
Durationint`json:"duration"`// Duration of the video in seconds as defined by sender
Thumbnail*PhotoSize`json:"thumb"`// Thumbnail animation thumbnail as defined by sender
FileNamestring`json:"file_name"`// FileName original animation filename as defined by sender
MimeTypestring`json:"mime_type"`// MimeType of the file as defined by sender
// Audio represents an audio file to be treated as music by the Telegram clients.
typeAudiostruct{
FileIDstring`json:"file_id"`// FileID is an identifier for this file, which can be used to download or reuse the file
FileUniqueIDstring`json:"file_unique_id"`// FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
Durationint`json:"duration"`// Duration of the audio in seconds as defined by sender
Performerstring`json:"performer"`// Performer of the audio as defined by sender or by audio tags
Titlestring`json:"title"`// Title of the audio as defined by sender or by audio tags
FileNamestring`json:"file_name"`// FileName is the original filename as defined by sender
MimeTypestring`json:"mime_type"`// MimeType of the file as defined by sender
_,err:=b.SendReplyMessage(ctx,message.Chat.ID,message.MessageID,"Supported messages: animation, audio, text, document, photo, video, video note, voice, other messages with caption")
iferr!=nil{
slog.Error("fail to send reply message",err)
}
continue
}
// Group message need do more
ifmessage.MediaGroupID!=nil{
groupMessages=append(groupMessages,message)
continue
}
singleMessages=append(singleMessages,message)
continue
}
}
err=b.handleSingleMessages(ctx,singleMessages)
iferr!=nil{
slog.Error("fail to handle plain text message",err)
}
err=b.handleGroupMessages(ctx,groupMessages)
iferr!=nil{
slog.Error("fail to handle media group message",err)
FileIDstring`json:"file_id"`// FileID is an identifier for this file, which can be used to download or reuse the file
FileUniqueIDstring`json:"file_unique_id"`// FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
Thumbnail*PhotoSize`json:"thumb"`// Thumbnail document thumbnail as defined by sender
FileNamestring`json:"file_name"`// FileName original filename as defined by sender
MimeTypestring`json:"mime_type"`// MimeType of the file as defined by sender
MessageIDint64`json:"message_id"`// MessageID is a unique message identifier inside this chat
FromUser`json:"from"`// From is a sender, empty for messages sent to channels;
Dateint`json:"date"`// Date of the message was sent in Unix time
Text*string`json:"text"`// Text is for text messages, the actual UTF-8 text of the message, 0-4096 characters;
Chat*Chat`json:"chat"`// Chat is the conversation the message belongs to
ForwardFromChat*Chat`json:"forward_from_chat"`// ForwardFromChat for messages forwarded from channels, information about the original channel;
ForwardFromMessageIDint64`json:"forward_from_message_id"`// ForwardFromMessageID for messages forwarded from channels, identifier of the original message in the channel;
MediaGroupID*string`json:"media_group_id"`// MediaGroupID is the unique identifier of a media message group this message belongs to;
Photo[]PhotoSize`json:"photo"`// Photo message is a photo, available sizes of the photo;
Caption*string`json:"caption"`// Caption for the animation, audio, document, photo, video or voice, 0-1024 characters;
Entities[]MessageEntity`json:"entities"`// Entities are for text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text;
CaptionEntities[]MessageEntity`json:"caption_entities"`// CaptionEntities are for messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption;
Document*Document`json:"document"`// Document message is a general file, information about the file;
Video*Video`json:"video"`// Video message is a video, information about the video;
VideoNote*VideoNote`json:"video_note"`// VideoNote message is a video note, information about the video message;
Voice*Voice`json:"voice"`// Voice message is a voice message, information about the file;
Audio*Audio`json:"audio"`// Audio message is an audio file, information about the file;
Animation*Animation`json:"animation"`// Animation message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set;
FileIDstring`json:"file_id"`// FileID identifier for this file, which can be used to download or reuse
FileUniqueIDstring`json:"file_unique_id"`// FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
Widthint`json:"width"`// Width video width as defined by sender
Heightint`json:"height"`// Height video height as defined by sender
Durationint`json:"duration"`// Duration of the video in seconds as defined by sender
Thumbnail*PhotoSize`json:"thumb"`// Thumbnail video thumbnail
FileNamestring`json:"file_name"`// FileName is the original filename as defined by sender
MimeTypestring`json:"mime_type"`// MimeType of a file as defined by sender
FileIDstring`json:"file_id"`// FileID identifier for this file, which can be used to download or reuse the file
FileUniqueIDstring`json:"file_unique_id"`// FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
Lengthint`json:"length"`// Length video width and height (diameter of the video message) as defined by sender
Durationint`json:"duration"`// Duration of the video in seconds as defined by sender
Thumbnail*PhotoSize`json:"thumb,omitempty"`// Thumbnail video thumbnail
FileIDstring`json:"file_id"`// FileID identifier for this file, which can be used to download or reuse the file
FileUniqueIDstring`json:"file_unique_id"`// FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
Durationint`json:"duration"`// Duration of the audio in seconds as defined by sender
MimeTypestring`json:"mime_type"`// MimeType of the file as defined by sender
// If creatorID is not found, ask the user to set the telegram userid in UserSetting of memos.
ifcreatorID==0{
_,err:=bot.EditMessage(ctx,message.Chat.ID,reply.MessageID,fmt.Sprintf("Please set your telegram userid %d in UserSetting of memos",message.From.ID),nil)
returnbot.AnswerCallbackQuery(ctx,callbackQuery.ID,fmt.Sprintf("Failed to changing Memo %d to %s\n(workspace disallowed public memo)",memoID,visibility))
}
update:=store.UpdateMemo{
ID:memoID,
Visibility:&visibility,
}
err=t.store.UpdateMemo(ctx,&update)
iferr!=nil{
returnbot.AnswerCallbackQuery(ctx,callbackQuery.ID,fmt.Sprintf("Failed to call UpdateMemo %s",err))
}
keyboard:=generateKeyboardForMemoID(memoID)
_,err=bot.EditMessage(ctx,callbackQuery.Message.Chat.ID,callbackQuery.Message.MessageID,fmt.Sprintf("Saved as %s Memo %d",visibility,memoID),keyboard)
iferr!=nil{
returnbot.AnswerCallbackQuery(ctx,callbackQuery.ID,fmt.Sprintf("Failed to EditMessage %s",err))
}
err=bot.AnswerCallbackQuery(ctx,callbackQuery.ID,fmt.Sprintf("Success changing Memo %d to %s",memoID,visibility))