diff --git a/.gitignore b/.gitignore
index fd877c31..c6f671d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,7 +21,8 @@ dist/
# Executables
Alita_Robot
Alita_Robot.exe
-*.env
+.env
+.db.env
# Mac OS DS_Store file
.DS_Store
diff --git a/alita/db/lang_db.go b/alita/db/lang_db.go
index c1a9a5a1..711707f4 100644
--- a/alita/db/lang_db.go
+++ b/alita/db/lang_db.go
@@ -8,11 +8,11 @@ import (
)
func GetLanguage(ctx *ext.Context) string {
- var chat *gotgbot.Chat
+ var chat gotgbot.Chat
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ chat = ctx.CallbackQuery.Message.GetChat()
} else {
- chat = &ctx.Update.Message.Chat
+ chat = ctx.Update.Message.Chat
}
// FIXME: this is a hack
// if ctx.Update.Message.Chat.Type == "private" || ctx.CallbackQuery.Message.Chat.Type == "private" {
diff --git a/alita/modules/bans.go b/alita/modules/bans.go
index 3987d65b..684eaa46 100644
--- a/alita/modules/bans.go
+++ b/alita/modules/bans.go
@@ -1126,14 +1126,17 @@ func (moduleStruct) unrestrictButtonHandler(b *gotgbot.Bot, ctx *ext.Context) er
)
}
+ // type assertion to get the message
+ _updatedMsg := msg.(*gotgbot.Message)
+
// only strikethrough if msg.Text is non-empty
- if msg.Text != "" {
- msg.Text = fmt.Sprint("", msg.Text, "", "\n\n")
+ if _updatedMsg.Text != "" {
+ _updatedMsg.Text = fmt.Sprint("", _updatedMsg.Text, "", "\n\n")
}
_, _, err := msg.EditText(
b,
- fmt.Sprint(msg.Text, helpText),
+ fmt.Sprint(_updatedMsg.Text, helpText),
&gotgbot.EditMessageTextOpts{
ParseMode: helpers.HTML,
},
diff --git a/alita/modules/blacklists.go b/alita/modules/blacklists.go
index c7af2696..c26d1c19 100644
--- a/alita/modules/blacklists.go
+++ b/alita/modules/blacklists.go
@@ -220,9 +220,11 @@ func (m moduleStruct) listBlacklists(b *gotgbot.Bot, ctx *ext.Context) error {
_, err := msg.Reply(b,
blacklistsText,
&gotgbot.SendMessageOpts{
- ReplyToMessageId: replyMsgId,
- AllowSendingWithoutReply: true,
- ParseMode: helpers.HTML,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ParseMode: helpers.HTML,
},
)
if err != nil {
@@ -341,7 +343,7 @@ func (m moduleStruct) buttonHandler(b *gotgbot.Bot, ctx *ext.Context) error {
switch creatorAction {
case "yes":
- go db.RemoveAllBlacklist(query.Message.Chat.Id)
+ go db.RemoveAllBlacklist(query.Message.GetChat().Id)
helpText = tr.GetString("strings." + m.moduleName + ".rm_all_bl.button_handler.yes")
case "no":
helpText = tr.GetString("strings." + m.moduleName + ".rm_all_bl.button_handler.yes")
diff --git a/alita/modules/connections.go b/alita/modules/connections.go
index e7e018a8..aa4ba847 100644
--- a/alita/modules/connections.go
+++ b/alita/modules/connections.go
@@ -327,7 +327,7 @@ func (m moduleStruct) reconnect(b *gotgbot.Bot, ctx *ext.Context) error {
return err
}
- if !chat_status.IsUserInChat(b, gchat, user.Id) {
+ if !chat_status.IsUserInChat(b, gchat.PersonalChat, user.Id) {
return ext.EndGroups
}
diff --git a/alita/modules/devs.go b/alita/modules/devs.go
index a38c82fe..3542d099 100644
--- a/alita/modules/devs.go
+++ b/alita/modules/devs.go
@@ -49,7 +49,7 @@ func (moduleStruct) chatInfo(b *gotgbot.Bot, ctx *ext.Context) error {
_, _ = msg.Reply(b, err.Error(), nil)
return ext.EndGroups
}
- con, _ := chat.GetMemberCount(b, nil)
+ con, _ := chat.PersonalChat.GetMemberCount(b, nil)
replyText = fmt.Sprintf("Name: %s\nChat ID: %d\nUsers Count: %d\nLink: %s", chat.Title, chat.Id, con, chat.InviteLink)
}
@@ -112,11 +112,13 @@ func (moduleStruct) chatList(b *gotgbot.Bot, ctx *ext.Context) error {
_, err = b.SendDocument(
chat.Id,
- openedFile,
+ gotgbot.InputFileByReader(fileName, openedFile),
&gotgbot.SendDocumentOpts{
- Caption: "Here is the list of chats in my Database!",
- ReplyToMessageId: msg.MessageId,
- AllowSendingWithoutReply: true,
+ Caption: "Here is the list of chats in my Database!",
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: msg.MessageId,
+ AllowSendingWithoutReply: true,
+ },
},
)
if err != nil {
diff --git a/alita/modules/disabling.go b/alita/modules/disabling.go
index 33bdb129..9adee2de 100644
--- a/alita/modules/disabling.go
+++ b/alita/modules/disabling.go
@@ -135,8 +135,10 @@ func (moduleStruct) disabled(b *gotgbot.Bot, ctx *ext.Context) error {
_, err := msg.Reply(b,
"There are no disabled commands in this chat.",
&gotgbot.SendMessageOpts{
- ReplyToMessageId: replyMsgId,
- AllowSendingWithoutReply: true,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
},
)
if err != nil {
diff --git a/alita/modules/filters.go b/alita/modules/filters.go
index 85a46c99..f43ed8c8 100644
--- a/alita/modules/filters.go
+++ b/alita/modules/filters.go
@@ -240,9 +240,11 @@ func (moduleStruct) filtersList(b *gotgbot.Bot, ctx *ext.Context) error {
_, err := msg.Reply(b,
info,
&gotgbot.SendMessageOpts{
- ParseMode: helpers.HTML,
- ReplyToMessageId: replyMsgId,
- AllowSendingWithoutReply: true,
+ ParseMode: helpers.HTML,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
},
)
if err != nil {
diff --git a/alita/modules/formatting.go b/alita/modules/formatting.go
index 75ab31be..ffcc224c 100644
--- a/alita/modules/formatting.go
+++ b/alita/modules/formatting.go
@@ -130,7 +130,7 @@ func (m moduleStruct) formattingHandler(b *gotgbot.Bot, ctx *ext.Context) error
_, _, err := msg.EditText(b,
m.getMarkdownHelp(module),
&gotgbot.EditMessageTextOpts{
- MessageId: msg.MessageId,
+ MessageId: msg.GetMessageId(),
ReplyMarkup: gotgbot.InlineKeyboardMarkup{
InlineKeyboard: [][]gotgbot.InlineKeyboardButton{
{
diff --git a/alita/modules/help.go b/alita/modules/help.go
index 8d381ab3..12c02fe3 100644
--- a/alita/modules/help.go
+++ b/alita/modules/help.go
@@ -184,9 +184,11 @@ func (moduleStruct) about(b *gotgbot.Bot, ctx *ext.Context) error {
_, _, err := query.Message.EditText(b,
currText,
&gotgbot.EditMessageTextOpts{
- ReplyMarkup: currKb,
- DisableWebPagePreview: true,
- ParseMode: helpers.HTML,
+ ReplyMarkup: currKb,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
+ ParseMode: helpers.HTML,
},
)
if err != nil {
@@ -220,9 +222,11 @@ func (moduleStruct) about(b *gotgbot.Bot, ctx *ext.Context) error {
b,
currText,
&gotgbot.SendMessageOpts{
- ParseMode: helpers.HTML,
- DisableWebPagePreview: true,
- ReplyMarkup: &currKb,
+ ParseMode: helpers.HTML,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
+ ReplyMarkup: &currKb,
},
)
if err != nil {
@@ -267,9 +271,11 @@ func (moduleStruct) helpButtonHandler(b *gotgbot.Bot, ctx *ext.Context) error {
b,
helpText,
&gotgbot.EditMessageTextOpts{
- ParseMode: _parsemode,
- ReplyMarkup: replyKb,
- DisableWebPagePreview: true,
+ ParseMode: _parsemode,
+ ReplyMarkup: replyKb,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
},
)
if err != nil {
@@ -297,9 +303,11 @@ func (moduleStruct) start(b *gotgbot.Bot, ctx *ext.Context) error {
_, err := msg.Reply(b,
startHelp,
&gotgbot.SendMessageOpts{
- ParseMode: helpers.HTML,
- DisableWebPagePreview: true,
- ReplyMarkup: &startMarkup,
+ ParseMode: helpers.HTML,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
+ ReplyMarkup: &startMarkup,
},
)
if err != nil {
@@ -332,10 +340,14 @@ func (moduleStruct) donate(b *gotgbot.Bot, ctx *ext.Context) error {
_, err := b.SendMessage(chat.Id,
i18n.I18n{LangCode: "en"}.GetString("strings.Help.DonateText"),
&gotgbot.SendMessageOpts{
- ParseMode: helpers.HTML,
- DisableWebPagePreview: true,
- ReplyToMessageId: msg.MessageId,
- AllowSendingWithoutReply: true,
+ ParseMode: helpers.HTML,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: msg.MessageId,
+ AllowSendingWithoutReply: true,
+ },
},
)
if err != nil {
@@ -350,7 +362,7 @@ func (moduleStruct) botConfig(b *gotgbot.Bot, ctx *ext.Context) error {
msg := query.Message
// just in case
- if msg.Chat.Type != "private" {
+ if msg.GetChat().Type != "private" {
_, _, err := msg.EditText(b, "Configuration only works in private", nil)
if err != nil {
log.Error(err)
@@ -410,7 +422,9 @@ func (moduleStruct) botConfig(b *gotgbot.Bot, ctx *ext.Context) error {
b,
text,
&gotgbot.EditMessageTextOpts{
- DisableWebPagePreview: true,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
ReplyMarkup: gotgbot.InlineKeyboardMarkup{
InlineKeyboard: iKeyboard,
},
@@ -491,9 +505,11 @@ func (moduleStruct) help(b *gotgbot.Bot, ctx *ext.Context) error {
_, err := msg.Reply(b,
moduleHelpString,
&gotgbot.SendMessageOpts{
- ParseMode: helpers.HTML,
- ReplyToMessageId: replyMsgId,
- AllowSendingWithoutReply: true,
+ ParseMode: helpers.HTML,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
ReplyMarkup: gotgbot.InlineKeyboardMarkup{
InlineKeyboard: [][]gotgbot.InlineKeyboardButton{
{
diff --git a/alita/modules/helpers.go b/alita/modules/helpers.go
index d71bade4..bce5b742 100644
--- a/alita/modules/helpers.go
+++ b/alita/modules/helpers.go
@@ -245,7 +245,7 @@ func startHelpPrefixHandler(b *gotgbot.Bot, ctx *ext.Context, user *gotgbot.User
return ext.ContinueGroups
}
}
- _, err := helpers.SendNote(b, chatinfo, ctx, noteData, msg.MessageId)
+ _, err := helpers.SendNote(b, chatinfo.PersonalChat, ctx, noteData, msg.MessageId)
if err != nil {
log.Error(err)
return err
@@ -255,11 +255,15 @@ func startHelpPrefixHandler(b *gotgbot.Bot, ctx *ext.Context, user *gotgbot.User
_, err := b.SendMessage(chat.Id,
aboutText,
&gotgbot.SendMessageOpts{
- ParseMode: "Markdown",
- DisableWebPagePreview: true,
- ReplyToMessageId: msg.MessageId,
- ReplyMarkup: &aboutKb,
- AllowSendingWithoutReply: true,
+ ParseMode: "Markdown",
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: msg.MessageId,
+ AllowSendingWithoutReply: true,
+ },
+ ReplyMarkup: &aboutKb,
},
)
if err != nil {
@@ -271,9 +275,11 @@ func startHelpPrefixHandler(b *gotgbot.Bot, ctx *ext.Context, user *gotgbot.User
_, err := b.SendMessage(chat.Id,
startHelp,
&gotgbot.SendMessageOpts{
- ParseMode: helpers.HTML,
- DisableWebPagePreview: true,
- ReplyMarkup: &startMarkup,
+ ParseMode: helpers.HTML,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
+ ReplyMarkup: &startMarkup,
},
)
if err != nil {
diff --git a/alita/modules/language.go b/alita/modules/language.go
index ba0bec29..4bd3814b 100644
--- a/alita/modules/language.go
+++ b/alita/modules/language.go
@@ -72,7 +72,7 @@ func (m moduleStruct) changeLanguage(b *gotgbot.Bot, ctx *ext.Context) error {
func (moduleStruct) langBtnHandler(b *gotgbot.Bot, ctx *ext.Context) error {
query := ctx.Update.CallbackQuery
- chat := query.Message.Chat
+ chat := query.Message.GetChat()
user := query.From
var replyString string
@@ -90,8 +90,10 @@ func (moduleStruct) langBtnHandler(b *gotgbot.Bot, ctx *ext.Context) error {
b,
replyString,
&gotgbot.EditMessageTextOpts{
- ParseMode: helpers.HTML,
- DisableWebPagePreview: true,
+ ParseMode: helpers.HTML,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
},
)
if err != nil {
diff --git a/alita/modules/misc.go b/alita/modules/misc.go
index 1eabc19e..858233ac 100644
--- a/alita/modules/misc.go
+++ b/alita/modules/misc.go
@@ -53,8 +53,10 @@ func (moduleStruct) echomsg(b *gotgbot.Bot, ctx *ext.Context) error {
strings.Split(msg.OriginalHTML(), " ")[1:], " ",
),
&gotgbot.SendMessageOpts{
- ReplyToMessageId: replyMsg.MessageId,
- ParseMode: helpers.Shtml().ParseMode,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsg.MessageId,
+ },
+ ParseMode: helpers.Shtml().ParseMode,
},
)
if err != nil {
@@ -98,18 +100,28 @@ func (moduleStruct) getId(b *gotgbot.Bot, ctx *ext.Context) error {
originalId,
)
}
- if msg.ReplyToMessage.ForwardFrom != nil {
- user1Id := msg.ReplyToMessage.ForwardFrom.Id
- _, user1Name, _ := extraction.GetUserInfo(user1Id)
- replyText += fmt.Sprintf(
- "Forwarded from %s's ID: %d
\n",
- user1Name, user1Id,
- )
- }
- if msg.ReplyToMessage.ForwardFromChat != nil {
- replyText += fmt.Sprintf("Forwarded from chat %s's ID: %d
\n",
- msg.ReplyToMessage.ForwardFromChat.Title, msg.ReplyToMessage.ForwardFromChat.Id,
- )
+
+ if rpm := msg.ReplyToMessage; rpm != nil {
+ if frpm := rpm.ForwardOrigin; frpm != nil {
+ if frpm.GetDate() != 0 {
+ fwdd := frpm.MergeMessageOrigin()
+
+ if fwdc := fwdd.SenderUser; fwdc != nil {
+ user1Id := fwdc.Id
+ _, user1Name, _ := extraction.GetUserInfo(user1Id)
+ replyText += fmt.Sprintf(
+ "Forwarded from %s's ID: %d
\n",
+ user1Name, user1Id,
+ )
+ }
+
+ if fwdc := fwdd.Chat; fwdc != nil {
+ replyText += fmt.Sprintf("Forwarded from chat %s's ID: %d
\n",
+ fwdc.Title, fwdc.Id,
+ )
+ }
+ }
+ }
}
if msg.ReplyToMessage.Animation != nil {
replyText += fmt.Sprintf("GIF ID: %s
\n",
@@ -199,7 +211,7 @@ func (moduleStruct) paste(b *gotgbot.Bot, ctx *ext.Context) error {
return ext.EndGroups
}
fileName := fmt.Sprintf("paste_%d_%d.txt", msg.Chat.Id, msg.MessageId)
- raw, err := http.Get(config.ApiServer + "/file/bot" + b.GetToken() + "/" + f.FilePath)
+ raw, err := http.Get(config.ApiServer + "/file/bot" + config.BotToken + "/" + f.FilePath)
if err != nil {
log.Error(err)
}
@@ -235,8 +247,10 @@ func (moduleStruct) paste(b *gotgbot.Bot, ctx *ext.Context) error {
if pasted {
_, _, err = edited.EditText(b, fmt.Sprintf("Pasted Successfully!\nhttps://www.nekobin.com/%s.%s", key, extention),
&gotgbot.EditMessageTextOpts{
- ParseMode: helpers.HTML,
- DisableWebPagePreview: true,
+ ParseMode: helpers.HTML,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
},
)
if err != nil {
diff --git a/alita/modules/notes.go b/alita/modules/notes.go
index cb8bed85..544005a7 100644
--- a/alita/modules/notes.go
+++ b/alita/modules/notes.go
@@ -427,7 +427,7 @@ func (moduleStruct) notesButtonHandler(b *gotgbot.Bot, ctx *ext.Context) error {
switch response {
case "yes":
- db.RemoveAllNotes(query.Message.Chat.Id)
+ db.RemoveAllNotes(query.Message.GetChat().Id)
helpText = "Removed all Notes from this Chat ✅"
case "no":
helpText = "Cancelled removing all notes from this Chat ❌"
@@ -523,8 +523,10 @@ func (m moduleStruct) notesWatcher(b *gotgbot.Bot, ctx *ext.Context) error {
_, err = msg.Reply(b,
fmt.Sprintf("Click on the button below to get the note *%s*", noteName),
&gotgbot.SendMessageOpts{
- ReplyToMessageId: replyMsgId,
- AllowSendingWithoutReply: true,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
ReplyMarkup: gotgbot.InlineKeyboardMarkup{
InlineKeyboard: [][]gotgbot.InlineKeyboardButton{
{
@@ -641,9 +643,11 @@ func (m moduleStruct) getNotes(b *gotgbot.Bot, ctx *ext.Context) error {
},
},
},
- ParseMode: helpers.Markdown,
- ReplyToMessageId: replyMsgId,
- AllowSendingWithoutReply: true,
+ ParseMode: helpers.Markdown,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
},
)
} else {
diff --git a/alita/modules/pin.go b/alita/modules/pin.go
index a084f402..356c5077 100644
--- a/alita/modules/pin.go
+++ b/alita/modules/pin.go
@@ -132,17 +132,19 @@ func (moduleStruct) unpin(b *gotgbot.Bot, ctx *ext.Context) error {
// if err.Error() == "unable to unpinChatMessage: Bad Request: message to unpin not found" {
// replyText = "No pinned message found."
// } else
- if err != nil {
- log.Error(err)
- return err
- }
+ // if err != nil {
+ log.Error(err)
+ return err
+ // }
}
}
_, err := msg.Reply(b, replyText,
&gotgbot.SendMessageOpts{
- ReplyToMessageId: replyMsgId,
- AllowSendingWithoutReply: true,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
},
)
if err != nil {
@@ -291,10 +293,14 @@ func (m moduleStruct) permaPin(b *gotgbot.Bot, ctx *ext.Context) error {
_, err = msg.Reply(b,
fmt.Sprintf("I have pinned this message", pinLink),
&gotgbot.SendMessageOpts{
- ParseMode: helpers.HTML,
- ReplyToMessageId: msgToPin,
- DisableWebPagePreview: true,
- AllowSendingWithoutReply: true,
+ ParseMode: helpers.HTML,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: msgToPin,
+ AllowSendingWithoutReply: true,
+ },
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
},
)
if err != nil {
@@ -581,10 +587,14 @@ func (moduleStruct) pinned(b *gotgbot.Bot, ctx *ext.Context) error {
_, err = msg.Reply(b,
fmt.Sprintf("Here is the pinned message.", pinLink),
&gotgbot.SendMessageOpts{
- ParseMode: helpers.HTML,
- DisableWebPagePreview: true,
- ReplyToMessageId: replyMsgId,
- AllowSendingWithoutReply: true,
+ ParseMode: helpers.HTML,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
ReplyMarkup: gotgbot.InlineKeyboardMarkup{
InlineKeyboard: [][]gotgbot.InlineKeyboardButton{
{
@@ -610,94 +620,110 @@ var PinsEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, pinT pinTyp
ctx.EffectiveChat.Id,
pinT.MsgText,
&gotgbot.SendMessageOpts{
- ParseMode: helpers.HTML,
- DisableWebPagePreview: true,
- ReplyToMessageId: replyMsgId,
- ReplyMarkup: keyb,
- AllowSendingWithoutReply: true,
- MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
+ ParseMode: helpers.HTML,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
+ ReplyMarkup: keyb,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
},
)
},
db.STICKER: func(b *gotgbot.Bot, ctx *ext.Context, pinT pinType, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64) (*gotgbot.Message, error) {
return b.SendSticker(
ctx.EffectiveChat.Id,
- pinT.FileID,
+ gotgbot.InputFileByID(pinT.FileID),
&gotgbot.SendStickerOpts{
- ReplyToMessageId: replyMsgId,
- ReplyMarkup: keyb,
- AllowSendingWithoutReply: true,
- MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ReplyMarkup: keyb,
+ MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
},
)
},
db.DOCUMENT: func(b *gotgbot.Bot, ctx *ext.Context, pinT pinType, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64) (*gotgbot.Message, error) {
return b.SendDocument(
ctx.EffectiveChat.Id,
- pinT.FileID,
+ gotgbot.InputFileByID(pinT.FileID),
&gotgbot.SendDocumentOpts{
- ReplyToMessageId: replyMsgId,
- ParseMode: helpers.HTML,
- ReplyMarkup: keyb,
- Caption: pinT.MsgText,
- AllowSendingWithoutReply: true,
- MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ParseMode: helpers.HTML,
+ ReplyMarkup: keyb,
+ Caption: pinT.MsgText,
+ MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
},
)
},
db.PHOTO: func(b *gotgbot.Bot, ctx *ext.Context, pinT pinType, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64) (*gotgbot.Message, error) {
return b.SendPhoto(
ctx.EffectiveChat.Id,
- pinT.FileID,
+ gotgbot.InputFileByID(pinT.FileID),
&gotgbot.SendPhotoOpts{
- ReplyToMessageId: replyMsgId,
- ParseMode: helpers.HTML,
- ReplyMarkup: keyb,
- Caption: pinT.MsgText,
- AllowSendingWithoutReply: true,
- MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ParseMode: helpers.HTML,
+ ReplyMarkup: keyb,
+ Caption: pinT.MsgText,
+ MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
},
)
},
db.AUDIO: func(b *gotgbot.Bot, ctx *ext.Context, pinT pinType, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64) (*gotgbot.Message, error) {
return b.SendAudio(
ctx.EffectiveChat.Id,
- pinT.FileID,
+ gotgbot.InputFileByID(pinT.FileID),
&gotgbot.SendAudioOpts{
- ReplyToMessageId: replyMsgId,
- ParseMode: helpers.HTML,
- ReplyMarkup: keyb,
- Caption: pinT.MsgText,
- AllowSendingWithoutReply: true,
- MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ParseMode: helpers.HTML,
+ ReplyMarkup: keyb,
+ Caption: pinT.MsgText,
+ MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
},
)
},
db.VOICE: func(b *gotgbot.Bot, ctx *ext.Context, pinT pinType, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64) (*gotgbot.Message, error) {
return b.SendVoice(
ctx.EffectiveChat.Id,
- pinT.FileID,
+ gotgbot.InputFileByID(pinT.FileID),
&gotgbot.SendVoiceOpts{
- ReplyToMessageId: replyMsgId,
- ParseMode: helpers.HTML,
- ReplyMarkup: keyb,
- Caption: pinT.MsgText,
- AllowSendingWithoutReply: true,
- MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ParseMode: helpers.HTML,
+ ReplyMarkup: keyb,
+ Caption: pinT.MsgText,
+ MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
},
)
},
db.VIDEO: func(b *gotgbot.Bot, ctx *ext.Context, pinT pinType, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64) (*gotgbot.Message, error) {
return b.SendVideo(
ctx.EffectiveChat.Id,
- pinT.FileID,
+ gotgbot.InputFileByID(pinT.FileID),
&gotgbot.SendVideoOpts{
- ReplyToMessageId: replyMsgId,
- ParseMode: helpers.HTML,
- ReplyMarkup: keyb,
- Caption: pinT.MsgText,
- AllowSendingWithoutReply: true,
- MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ParseMode: helpers.HTML,
+ ReplyMarkup: keyb,
+ Caption: pinT.MsgText,
+ MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
},
)
},
diff --git a/alita/modules/purges.go b/alita/modules/purges.go
index e81147bc..382ab328 100644
--- a/alita/modules/purges.go
+++ b/alita/modules/purges.go
@@ -31,8 +31,10 @@ func (moduleStruct) purgeMsgs(bot *gotgbot.Bot, chat *gotgbot.Chat, pFrom bool,
_, err = bot.SendMessage(chat.Id,
"You cannot delete messages over two days old. Please choose a more recent message.",
&gotgbot.SendMessageOpts{
- ReplyToMessageId: deleteTo + 1,
- AllowSendingWithoutReply: true,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: deleteTo + 1,
+ AllowSendingWithoutReply: true,
+ },
},
)
if err != nil {
@@ -268,7 +270,15 @@ func (moduleStruct) purgeFrom(bot *gotgbot.Bot, ctx *ext.Context) error {
_, _ = msg.Reply(bot, err.Error(), nil)
return ext.EndGroups
}
- pMsg, err := bot.SendMessage(chat.Id, "Message marked for deletion. Reply to another message with /purgeto to delete all messages in between; within 30s!", &gotgbot.SendMessageOpts{ReplyToMessageId: TodelId})
+ pMsg, err := bot.SendMessage(chat.Id,
+ "Message marked for deletion. Reply to another message with /purgeto to delete all messages in between; within 30s!",
+ &gotgbot.SendMessageOpts{
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: TodelId,
+ AllowSendingWithoutReply: true,
+ },
+ },
+ )
if err != nil {
log.Error(err)
return err
diff --git a/alita/modules/reports.go b/alita/modules/reports.go
index 44445309..b131f06e 100644
--- a/alita/modules/reports.go
+++ b/alita/modules/reports.go
@@ -146,9 +146,11 @@ func (moduleStruct) report(b *gotgbot.Bot, ctx *ext.Context) error {
_, err = msg.Reply(b,
reported,
&gotgbot.SendMessageOpts{
- ParseMode: helpers.HTML,
- ReplyToMessageId: replyMsgId,
- AllowSendingWithoutReply: true,
+ ParseMode: helpers.HTML,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
ReplyMarkup: gotgbot.InlineKeyboardMarkup{
InlineKeyboard: [][]gotgbot.InlineKeyboardButton{
{
diff --git a/alita/modules/rules.go b/alita/modules/rules.go
index 0b27c963..3d371204 100644
--- a/alita/modules/rules.go
+++ b/alita/modules/rules.go
@@ -134,10 +134,12 @@ func (m moduleStruct) sendRules(bot *gotgbot.Bot, ctx *ext.Context) error {
_, err = msg.Reply(bot, Text,
&gotgbot.SendMessageOpts{
- ReplyMarkup: rulesKb,
- ReplyToMessageId: replyMsgId,
- AllowSendingWithoutReply: true,
- ParseMode: helpers.HTML,
+ ReplyMarkup: rulesKb,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ParseMode: helpers.HTML,
},
)
if err != nil {
diff --git a/alita/modules/users.go b/alita/modules/users.go
index 92eacd97..4d095c53 100644
--- a/alita/modules/users.go
+++ b/alita/modules/users.go
@@ -71,21 +71,22 @@ func (moduleStruct) logUsers(bot *gotgbot.Bot, ctx *ext.Context) error {
}
// update if message is forwarded
- if msg.ForwardFrom != nil || msg.ForwardFromChat != nil {
- if msg.ForwardFromChat != nil && msg.ForwardFromChat.Type != "group" {
+ if msg.ForwardOrigin != nil {
+ forwarded := msg.ForwardOrigin.MergeMessageOrigin()
+ if forwarded.Chat != nil && forwarded.Chat.Type != "group" {
go db.UpdateChannel(
- msg.ForwardFromChat.Id,
- msg.ForwardFromChat.Title,
- msg.ForwardFromChat.Username,
+ forwarded.Chat.Id,
+ forwarded.Chat.Title,
+ forwarded.Chat.Username,
)
- } else {
+ } else if forwarded.SenderUser != nil {
// if chat type is not group
go db.UpdateUser(
- msg.ForwardFrom.Id,
- msg.ForwardFrom.Username,
+ forwarded.SenderUser.Id,
+ forwarded.SenderUser.Username,
helpers.GetFullName(
- msg.ForwardFrom.FirstName,
- msg.ForwardFrom.LastName,
+ forwarded.SenderUser.FirstName,
+ forwarded.SenderUser.LastName,
),
)
}
diff --git a/alita/modules/warns.go b/alita/modules/warns.go
index 39dd04b8..58767c96 100644
--- a/alita/modules/warns.go
+++ b/alita/modules/warns.go
@@ -193,11 +193,15 @@ func (moduleStruct) warnThisUser(b *gotgbot.Bot, ctx *ext.Context, userId int64,
}
_, err = b.SendMessage(chat.Id, reply,
&gotgbot.SendMessageOpts{
- ParseMode: helpers.HTML,
- DisableWebPagePreview: true,
- ReplyToMessageId: msg.MessageId,
- AllowSendingWithoutReply: true,
- ReplyMarkup: &keyboard,
+ ParseMode: helpers.HTML,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: msg.MessageId,
+ AllowSendingWithoutReply: true,
+ },
+ ReplyMarkup: &keyboard,
},
)
if err != nil {
@@ -663,7 +667,7 @@ func (moduleStruct) warnsButtonHandler(b *gotgbot.Bot, ctx *ext.Context) error {
switch response {
case "yes":
- go db.ResetAllChatWarns(query.Message.Chat.Id)
+ go db.ResetAllChatWarns(query.Message.GetChat().Id)
helpText = "Removed all warns of all the users in this chat !"
case "no":
helpText = "Cancelled the removal of all the warns of all the users in this chat !"
diff --git a/alita/utils/chat_status/chat_status.go b/alita/utils/chat_status/chat_status.go
index f1c8dce5..9409958a 100644
--- a/alita/utils/chat_status/chat_status.go
+++ b/alita/utils/chat_status/chat_status.go
@@ -92,11 +92,11 @@ func IsUserAdmin(b *gotgbot.Bot, chatID, userId int64) bool {
adminsAvail, admins := cache.GetAdminCacheList(chat.Id)
if !adminsAvail {
- admins = cache.LoadAdminCache(b, chat)
+ admins = cache.LoadAdminCache(b, chat.PersonalChat)
}
if !admins.Cached {
- adminList, err := chat.GetAdministrators(b, nil)
+ adminList, err := chat.PersonalChat.GetAdministrators(b, nil)
if err != nil {
log.Error(err)
return false
@@ -117,7 +117,8 @@ func IsUserAdmin(b *gotgbot.Bot, chatID, userId int64) bool {
func IsBotAdmin(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -136,7 +137,8 @@ func IsBotAdmin(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat) bool {
func CanUserChangeInfo(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userId int64, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -180,7 +182,14 @@ func CanUserChangeInfo(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, use
return false
}
if !justCheck {
- _, err := b.SendMessage(chat.Id, "You don't have permission to change info in this group!", &gotgbot.SendMessageOpts{ReplyToMessageId: ctx.EffectiveMessage.MessageId})
+ _, err := b.SendMessage(chat.Id, "You don't have permission to change info in this group!",
+ &gotgbot.SendMessageOpts{
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: ctx.EffectiveMessage.MessageId,
+ AllowSendingWithoutReply: true,
+ },
+ },
+ )
error_handling.HandleErr(err)
}
return false
@@ -191,7 +200,8 @@ func CanUserChangeInfo(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, use
func CanUserRestrict(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userId int64, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -234,7 +244,14 @@ func CanUserRestrict(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userI
return false
}
if !justCheck {
- _, err := b.SendMessage(chat.Id, "You don't have permission to restrict users in this group!", &gotgbot.SendMessageOpts{ReplyToMessageId: ctx.EffectiveMessage.MessageId})
+ _, err := b.SendMessage(chat.Id, "You don't have permission to restrict users in this group!",
+ &gotgbot.SendMessageOpts{
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: ctx.EffectiveMessage.MessageId,
+ AllowSendingWithoutReply: true,
+ },
+ },
+ )
error_handling.HandleErr(err)
}
return false
@@ -245,7 +262,8 @@ func CanUserRestrict(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userI
func CanBotRestrict(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -266,7 +284,14 @@ func CanBotRestrict(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justCh
return false
}
if !justCheck {
- _, err := b.SendMessage(chat.Id, "I can't restrict people here! Make sure I'm admin and can restrict other members.", &gotgbot.SendMessageOpts{ReplyToMessageId: ctx.EffectiveMessage.MessageId})
+ _, err := b.SendMessage(chat.Id, "I can't restrict people here! Make sure I'm admin and can restrict other members.",
+ &gotgbot.SendMessageOpts{
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: ctx.EffectiveMessage.MessageId,
+ AllowSendingWithoutReply: true,
+ },
+ },
+ )
error_handling.HandleErr(err)
}
return false
@@ -277,7 +302,8 @@ func CanBotRestrict(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justCh
func CanUserPromote(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userId int64, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -320,7 +346,14 @@ func CanUserPromote(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userId
return false
}
if !justCheck {
- _, err := b.SendMessage(chat.Id, "You can't promote/demote people here! Make sure you have appropriate rights!", &gotgbot.SendMessageOpts{ReplyToMessageId: ctx.EffectiveMessage.MessageId})
+ _, err := b.SendMessage(chat.Id, "You can't promote/demote people here! Make sure you have appropriate rights!",
+ &gotgbot.SendMessageOpts{
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: ctx.EffectiveMessage.MessageId,
+ AllowSendingWithoutReply: true,
+ },
+ },
+ )
error_handling.HandleErr(err)
}
return false
@@ -331,7 +364,8 @@ func CanUserPromote(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userId
func CanBotPromote(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -341,7 +375,14 @@ func CanBotPromote(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justChe
error_handling.HandleErr(err)
if !botChatMember.MergeChatMember().CanPromoteMembers {
if !justCheck {
- _, err := b.SendMessage(chat.Id, "I can't promote/demote people here! Make sure I'm admin and can appoint new admins.", &gotgbot.SendMessageOpts{ReplyToMessageId: ctx.EffectiveMessage.MessageId})
+ _, err := b.SendMessage(chat.Id, "I can't promote/demote people here! Make sure I'm admin and can appoint new admins.",
+ &gotgbot.SendMessageOpts{
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: ctx.EffectiveMessage.MessageId,
+ AllowSendingWithoutReply: true,
+ },
+ },
+ )
error_handling.HandleErr(err)
}
return false
@@ -352,7 +393,8 @@ func CanBotPromote(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justChe
func CanUserPin(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userId int64, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -384,7 +426,13 @@ func CanUserPin(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userId int
}
if !userMember.CanPinMessages && userMember.Status != "creator" {
if !justCheck {
- _, err := b.SendMessage(chat.Id, "You can't pin messages here! Make sure you're admin and can pin messages.", &gotgbot.SendMessageOpts{ReplyToMessageId: ctx.EffectiveMessage.MessageId})
+ _, err := b.SendMessage(chat.Id, "You can't pin messages here! Make sure you're admin and can pin messages.", &gotgbot.SendMessageOpts{
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: ctx.EffectiveMessage.MessageId,
+ AllowSendingWithoutReply: true,
+ },
+ },
+ )
error_handling.HandleErr(err)
}
return false
@@ -395,7 +443,8 @@ func CanUserPin(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userId int
func CanBotPin(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -405,7 +454,14 @@ func CanBotPin(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justCheck b
error_handling.HandleErr(err)
if !botChatMember.MergeChatMember().CanPinMessages {
if !justCheck {
- _, err := b.SendMessage(chat.Id, "I can't pin messages here! Make sure I'm admin and can pin messages.", &gotgbot.SendMessageOpts{ReplyToMessageId: ctx.EffectiveMessage.MessageId})
+ _, err := b.SendMessage(chat.Id, "I can't pin messages here! Make sure I'm admin and can pin messages.",
+ &gotgbot.SendMessageOpts{
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: ctx.EffectiveMessage.MessageId,
+ AllowSendingWithoutReply: true,
+ },
+ },
+ )
error_handling.HandleErr(err)
}
return false
@@ -416,7 +472,8 @@ func CanBotPin(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justCheck b
func Caninvite(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, msg *gotgbot.Message, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -428,7 +485,14 @@ func Caninvite(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, msg *gotgbo
error_handling.HandleErr(err)
if !botChatMember.MergeChatMember().CanInviteUsers {
if !justCheck {
- _, err := b.SendMessage(chat.Id, "I don't have access to invite links! Make sure I'm admin and can invite users.", &gotgbot.SendMessageOpts{ReplyToMessageId: ctx.EffectiveMessage.MessageId})
+ _, err := b.SendMessage(chat.Id, "I don't have access to invite links! Make sure I'm admin and can invite users.",
+ &gotgbot.SendMessageOpts{
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: ctx.EffectiveMessage.MessageId,
+ AllowSendingWithoutReply: true,
+ },
+ },
+ )
error_handling.HandleErr(err)
}
return false
@@ -457,7 +521,14 @@ func Caninvite(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, msg *gotgbo
}
if !userMember.CanInviteUsers && userMember.Status != "creator" {
if !justCheck {
- _, err := b.SendMessage(chat.Id, "You don't have access to invite links; You need to be admin to get this!", &gotgbot.SendMessageOpts{ReplyToMessageId: ctx.EffectiveMessage.MessageId})
+ _, err := b.SendMessage(chat.Id, "You don't have access to invite links; You need to be admin to get this!",
+ &gotgbot.SendMessageOpts{
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: ctx.EffectiveMessage.MessageId,
+ AllowSendingWithoutReply: true,
+ },
+ },
+ )
error_handling.HandleErr(err)
}
return false
@@ -468,7 +539,8 @@ func Caninvite(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, msg *gotgbo
func CanUserDelete(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userId int64, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -526,7 +598,8 @@ func CanUserDelete(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userId
func CanBotDelete(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -555,7 +628,8 @@ func CanBotDelete(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justChec
func RequireBotAdmin(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -586,7 +660,8 @@ func IsUserInChat(b *gotgbot.Bot, chat *gotgbot.Chat, userId int64) bool {
func IsUserBanProtected(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userId int64) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -602,7 +677,8 @@ func IsUserBanProtected(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, us
func RequireUserAdmin(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userId int64, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -633,7 +709,8 @@ func RequireUserAdmin(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, user
func RequireUserOwner(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, userId int64, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -671,7 +748,8 @@ func RequireUserOwner(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, user
func RequirePrivate(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -681,7 +759,9 @@ func RequirePrivate(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justCh
if !justCheck {
_, err := msg.Reply(b, "This command is made for pm, not group chat!",
&gotgbot.SendMessageOpts{
- ReplyToMessageId: msg.MessageId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: msg.MessageId,
+ },
},
)
error_handling.HandleErr(err)
@@ -694,7 +774,8 @@ func RequirePrivate(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justCh
func RequireGroup(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justCheck bool) bool {
if chat == nil {
if ctx.CallbackQuery != nil {
- chat = &ctx.CallbackQuery.Message.Chat
+ _chatValue := ctx.CallbackQuery.Message.GetChat()
+ chat = &_chatValue
} else {
chat = &ctx.Update.Message.Chat
}
@@ -704,7 +785,9 @@ func RequireGroup(b *gotgbot.Bot, ctx *ext.Context, chat *gotgbot.Chat, justChec
if !justCheck {
_, err := msg.Reply(b, "This command is made to be used in group chats, not in pm!",
&gotgbot.SendMessageOpts{
- ReplyToMessageId: msg.MessageId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: msg.MessageId,
+ },
},
)
error_handling.HandleErr(err)
diff --git a/alita/utils/extraction/extraction.go b/alita/utils/extraction/extraction.go
index b056f3bd..8b318460 100644
--- a/alita/utils/extraction/extraction.go
+++ b/alita/utils/extraction/extraction.go
@@ -35,7 +35,7 @@ func ExtractChat(b *gotgbot.Bot, ctx *ext.Context) *gotgbot.Chat {
}
return nil
}
- return chat
+ return chat.PersonalChat
} else {
chat, err := chat_status.GetChat(b, args[0])
if err != nil {
diff --git a/alita/utils/helpers/helpers.go b/alita/utils/helpers/helpers.go
index d6dd5392..59175a53 100644
--- a/alita/utils/helpers/helpers.go
+++ b/alita/utils/helpers/helpers.go
@@ -38,18 +38,26 @@ const (
// Shtml is a shortcut for SendMessageOpts with HTML parse mode.
func Shtml() *gotgbot.SendMessageOpts {
return &gotgbot.SendMessageOpts{
- ParseMode: HTML,
- DisableWebPagePreview: true,
- AllowSendingWithoutReply: true,
+ ParseMode: HTML,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
+ ReplyParameters: &gotgbot.ReplyParameters{
+ AllowSendingWithoutReply: true,
+ },
}
}
// Smarkdown is a shortcut for SendMessageOpts with Markdown parse mode.
func Smarkdown() *gotgbot.SendMessageOpts {
return &gotgbot.SendMessageOpts{
- ParseMode: Markdown,
- DisableWebPagePreview: true,
- AllowSendingWithoutReply: true,
+ ParseMode: Markdown,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
+ ReplyParameters: &gotgbot.ReplyParameters{
+ AllowSendingWithoutReply: true,
+ },
}
}
@@ -156,22 +164,24 @@ func IsUserConnected(b *gotgbot.Bot, ctx *ext.Context, chatAdmin, botAdmin bool)
msg := ctx.EffectiveMessage
user := ctx.EffectiveUser
tr := i18n.I18n{LangCode: db.GetLanguage(ctx)}
- var err error
if ctx.Update.Message.Chat.Type == "private" {
conn := db.Connection(user.Id)
if conn.Connected && conn.ChatId != 0 {
- chat, err = b.GetChat(conn.ChatId, nil)
+ chatFullInfo, err := b.GetChat(conn.ChatId, nil)
if err != nil {
log.Error(err)
return nil
}
+ chat = chatFullInfo.PersonalChat
} else {
_, err := msg.Reply(b,
tr.GetString("strings.Connections.is_user_connected.need_group"),
&gotgbot.SendMessageOpts{
- ReplyToMessageId: msg.MessageId,
- AllowSendingWithoutReply: true,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: msg.MessageId,
+ AllowSendingWithoutReply: true,
+ },
},
)
if err != nil {
@@ -844,27 +854,33 @@ var NotesEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, noteData *
return b.SendMessage(ctx.Update.Message.Chat.Id,
noteData.NoteContent,
&gotgbot.SendMessageOpts{
- ParseMode: formatMode,
- DisableWebPagePreview: !webPreview,
- ReplyMarkup: keyb,
- ReplyToMessageId: replyMsgId,
- AllowSendingWithoutReply: true,
- ProtectContent: isProtected,
- DisableNotification: noNotif,
- MessageThreadId: ctx.Update.Message.MessageThreadId,
+ ParseMode: formatMode,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: !webPreview,
+ },
+ ReplyMarkup: keyb,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ProtectContent: isProtected,
+ DisableNotification: noNotif,
+ MessageThreadId: ctx.Update.Message.MessageThreadId,
},
)
},
- db.STICKER: func(b *gotgbot.Bot, ctx *ext.Context, noteData *db.ChatNotes, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, _, isProtected bool, noFormat, noNotif bool) (*gotgbot.Message, error) {
+ db.STICKER: func(b *gotgbot.Bot, ctx *ext.Context, noteData *db.ChatNotes, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, _, isProtected bool, _, noNotif bool) (*gotgbot.Message, error) {
return b.SendSticker(ctx.Update.Message.Chat.Id,
- noteData.FileID,
+ gotgbot.InputFileByID(noteData.FileID),
&gotgbot.SendStickerOpts{
- ReplyToMessageId: replyMsgId,
- ReplyMarkup: keyb,
- AllowSendingWithoutReply: true,
- ProtectContent: isProtected,
- DisableNotification: noNotif,
- MessageThreadId: ctx.Update.Message.MessageThreadId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ReplyMarkup: keyb,
+ ProtectContent: isProtected,
+ DisableNotification: noNotif,
+ MessageThreadId: ctx.Update.Message.MessageThreadId,
},
)
},
@@ -874,16 +890,18 @@ var NotesEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, noteData *
formatMode = None
}
return b.SendDocument(ctx.Update.Message.Chat.Id,
- noteData.FileID,
+ gotgbot.InputFileByID(noteData.FileID),
&gotgbot.SendDocumentOpts{
- ReplyToMessageId: replyMsgId,
- ParseMode: formatMode,
- ReplyMarkup: keyb,
- Caption: noteData.NoteContent,
- AllowSendingWithoutReply: true,
- ProtectContent: isProtected,
- DisableNotification: noNotif,
- MessageThreadId: ctx.Update.Message.MessageThreadId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ParseMode: formatMode,
+ ReplyMarkup: keyb,
+ Caption: noteData.NoteContent,
+ ProtectContent: isProtected,
+ DisableNotification: noNotif,
+ MessageThreadId: ctx.Update.Message.MessageThreadId,
},
)
},
@@ -893,16 +911,18 @@ var NotesEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, noteData *
formatMode = None
}
return b.SendPhoto(ctx.Update.Message.Chat.Id,
- noteData.FileID,
+ gotgbot.InputFileByID(noteData.FileID),
&gotgbot.SendPhotoOpts{
- ReplyToMessageId: replyMsgId,
- ParseMode: formatMode,
- ReplyMarkup: keyb,
- Caption: noteData.NoteContent,
- AllowSendingWithoutReply: true,
- ProtectContent: isProtected,
- DisableNotification: noNotif,
- MessageThreadId: ctx.Update.Message.MessageThreadId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ParseMode: formatMode,
+ ReplyMarkup: keyb,
+ Caption: noteData.NoteContent,
+ ProtectContent: isProtected,
+ DisableNotification: noNotif,
+ MessageThreadId: ctx.Update.Message.MessageThreadId,
},
)
},
@@ -912,16 +932,18 @@ var NotesEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, noteData *
formatMode = None
}
return b.SendAudio(ctx.Update.Message.Chat.Id,
- noteData.FileID,
+ gotgbot.InputFileByID(noteData.FileID),
&gotgbot.SendAudioOpts{
- ReplyToMessageId: replyMsgId,
- ParseMode: formatMode,
- ReplyMarkup: keyb,
- Caption: noteData.NoteContent,
- AllowSendingWithoutReply: true,
- ProtectContent: isProtected,
- DisableNotification: noNotif,
- MessageThreadId: ctx.Update.Message.MessageThreadId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ParseMode: formatMode,
+ ReplyMarkup: keyb,
+ Caption: noteData.NoteContent,
+ ProtectContent: isProtected,
+ DisableNotification: noNotif,
+ MessageThreadId: ctx.Update.Message.MessageThreadId,
},
)
},
@@ -931,16 +953,18 @@ var NotesEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, noteData *
formatMode = None
}
return b.SendVoice(ctx.Update.Message.Chat.Id,
- noteData.FileID,
+ gotgbot.InputFileByID(noteData.FileID),
&gotgbot.SendVoiceOpts{
- ReplyToMessageId: replyMsgId,
- ParseMode: formatMode,
- ReplyMarkup: keyb,
- Caption: noteData.NoteContent,
- AllowSendingWithoutReply: true,
- ProtectContent: isProtected,
- DisableNotification: noNotif,
- MessageThreadId: ctx.Update.Message.MessageThreadId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ParseMode: formatMode,
+ ReplyMarkup: keyb,
+ Caption: noteData.NoteContent,
+ ProtectContent: isProtected,
+ DisableNotification: noNotif,
+ MessageThreadId: ctx.Update.Message.MessageThreadId,
},
)
},
@@ -950,29 +974,33 @@ var NotesEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, noteData *
formatMode = None
}
return b.SendVideo(ctx.Update.Message.Chat.Id,
- noteData.FileID,
+ gotgbot.InputFileByID(noteData.FileID),
&gotgbot.SendVideoOpts{
- ReplyToMessageId: replyMsgId,
- ParseMode: formatMode,
- ReplyMarkup: keyb,
- Caption: noteData.NoteContent,
- AllowSendingWithoutReply: true,
- ProtectContent: isProtected,
- DisableNotification: noNotif,
- MessageThreadId: ctx.Update.Message.MessageThreadId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ParseMode: formatMode,
+ ReplyMarkup: keyb,
+ Caption: noteData.NoteContent,
+ ProtectContent: isProtected,
+ DisableNotification: noNotif,
+ MessageThreadId: ctx.Update.Message.MessageThreadId,
},
)
},
- db.VideoNote: func(b *gotgbot.Bot, ctx *ext.Context, noteData *db.ChatNotes, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, _, isProtected bool, noFormat, noNotif bool) (*gotgbot.Message, error) {
+ db.VideoNote: func(b *gotgbot.Bot, ctx *ext.Context, noteData *db.ChatNotes, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, _, isProtected bool, _, noNotif bool) (*gotgbot.Message, error) {
return b.SendVideoNote(ctx.Update.Message.Chat.Id,
- noteData.FileID,
+ gotgbot.InputFileByID(noteData.FileID),
&gotgbot.SendVideoNoteOpts{
- ReplyToMessageId: replyMsgId,
- ReplyMarkup: keyb,
- AllowSendingWithoutReply: true,
- ProtectContent: isProtected,
- DisableNotification: noNotif,
- MessageThreadId: ctx.Update.Message.MessageThreadId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ AllowSendingWithoutReply: true,
+ },
+ ReplyMarkup: keyb,
+ ProtectContent: isProtected,
+ DisableNotification: noNotif,
+ MessageThreadId: ctx.Update.Message.MessageThreadId,
},
)
},
@@ -987,16 +1015,18 @@ var GreetingsEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, msg, f
ctx.EffectiveChat.Id,
msg,
&gotgbot.SendMessageOpts{
- ParseMode: HTML,
- DisableWebPagePreview: true,
- ReplyMarkup: keyb,
+ ParseMode: HTML,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
+ ReplyMarkup: keyb,
},
)
},
db.STICKER: func(b *gotgbot.Bot, ctx *ext.Context, _, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) {
return b.SendSticker(
ctx.EffectiveChat.Id,
- fileID,
+ gotgbot.InputFileByID(fileID),
&gotgbot.SendStickerOpts{
ReplyMarkup: keyb,
MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
@@ -1006,7 +1036,7 @@ var GreetingsEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, msg, f
db.DOCUMENT: func(b *gotgbot.Bot, ctx *ext.Context, msg, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) {
return b.SendDocument(
ctx.EffectiveChat.Id,
- fileID,
+ gotgbot.InputFileByID(fileID),
&gotgbot.SendDocumentOpts{
ParseMode: HTML,
ReplyMarkup: keyb,
@@ -1018,7 +1048,7 @@ var GreetingsEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, msg, f
db.PHOTO: func(b *gotgbot.Bot, ctx *ext.Context, msg, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) {
return b.SendPhoto(
ctx.EffectiveChat.Id,
- fileID,
+ gotgbot.InputFileByID(fileID),
&gotgbot.SendPhotoOpts{
ParseMode: HTML,
ReplyMarkup: keyb,
@@ -1030,7 +1060,7 @@ var GreetingsEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, msg, f
db.AUDIO: func(b *gotgbot.Bot, ctx *ext.Context, msg, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) {
return b.SendAudio(
ctx.EffectiveChat.Id,
- fileID,
+ gotgbot.InputFileByID(fileID),
&gotgbot.SendAudioOpts{
ParseMode: HTML,
ReplyMarkup: keyb,
@@ -1042,7 +1072,7 @@ var GreetingsEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, msg, f
db.VOICE: func(b *gotgbot.Bot, ctx *ext.Context, msg, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) {
return b.SendVoice(
ctx.EffectiveChat.Id,
- fileID,
+ gotgbot.InputFileByID(fileID),
&gotgbot.SendVoiceOpts{
ParseMode: HTML,
ReplyMarkup: keyb,
@@ -1054,7 +1084,7 @@ var GreetingsEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, msg, f
db.VIDEO: func(b *gotgbot.Bot, ctx *ext.Context, msg, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) {
return b.SendVideo(
ctx.EffectiveChat.Id,
- fileID,
+ gotgbot.InputFileByID(fileID),
&gotgbot.SendVideoOpts{
ParseMode: HTML,
ReplyMarkup: keyb,
@@ -1063,10 +1093,10 @@ var GreetingsEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, msg, f
},
)
},
- db.VideoNote: func(b *gotgbot.Bot, ctx *ext.Context, msg, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) {
+ db.VideoNote: func(b *gotgbot.Bot, ctx *ext.Context, _, fileID string, keyb *gotgbot.InlineKeyboardMarkup) (*gotgbot.Message, error) {
return b.SendVideoNote(
ctx.EffectiveChat.Id,
- fileID,
+ gotgbot.InputFileByID(fileID),
&gotgbot.SendVideoNoteOpts{
ReplyMarkup: keyb,
MessageThreadId: ctx.EffectiveMessage.MessageThreadId,
@@ -1087,21 +1117,27 @@ var FiltersEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, filterDa
ctx.Update.Message.Chat.Id,
filterData.FilterReply,
&gotgbot.SendMessageOpts{
- ParseMode: formatMode,
- DisableWebPagePreview: true,
- ReplyToMessageId: replyMsgId,
- ReplyMarkup: keyb,
- DisableNotification: noNotif,
- MessageThreadId: ctx.Update.Message.MessageThreadId,
+ ParseMode: formatMode,
+ LinkPreviewOptions: &gotgbot.LinkPreviewOptions{
+ IsDisabled: true,
+ },
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ },
+ ReplyMarkup: keyb,
+ DisableNotification: noNotif,
+ MessageThreadId: ctx.Update.Message.MessageThreadId,
},
)
},
- db.STICKER: func(b *gotgbot.Bot, ctx *ext.Context, filterData db.ChatFilters, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, noFormat, noNotif bool) (*gotgbot.Message, error) {
+ db.STICKER: func(b *gotgbot.Bot, ctx *ext.Context, filterData db.ChatFilters, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, _, noNotif bool) (*gotgbot.Message, error) {
return b.SendSticker(
ctx.Update.Message.Chat.Id,
- filterData.FileID,
+ gotgbot.InputFileByID(filterData.FileID),
&gotgbot.SendStickerOpts{
- ReplyToMessageId: replyMsgId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ },
ReplyMarkup: keyb,
DisableNotification: noNotif,
MessageThreadId: ctx.Update.Message.MessageThreadId,
@@ -1115,9 +1151,11 @@ var FiltersEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, filterDa
}
return b.SendDocument(
ctx.Update.Message.Chat.Id,
- filterData.FileID,
+ gotgbot.InputFileByID(filterData.FileID),
&gotgbot.SendDocumentOpts{
- ReplyToMessageId: replyMsgId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ },
ParseMode: formatMode,
ReplyMarkup: keyb,
Caption: filterData.FilterReply,
@@ -1133,9 +1171,11 @@ var FiltersEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, filterDa
}
return b.SendPhoto(
ctx.Update.Message.Chat.Id,
- filterData.FileID,
+ gotgbot.InputFileByID(filterData.FileID),
&gotgbot.SendPhotoOpts{
- ReplyToMessageId: replyMsgId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ },
ParseMode: formatMode,
ReplyMarkup: keyb,
Caption: filterData.FilterReply,
@@ -1151,9 +1191,11 @@ var FiltersEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, filterDa
}
return b.SendAudio(
ctx.Update.Message.Chat.Id,
- filterData.FileID,
+ gotgbot.InputFileByID(filterData.FileID),
&gotgbot.SendAudioOpts{
- ReplyToMessageId: replyMsgId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ },
ParseMode: formatMode,
ReplyMarkup: keyb,
Caption: filterData.FilterReply,
@@ -1169,9 +1211,11 @@ var FiltersEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, filterDa
}
return b.SendVoice(
ctx.Update.Message.Chat.Id,
- filterData.FileID,
+ gotgbot.InputFileByID(filterData.FileID),
&gotgbot.SendVoiceOpts{
- ReplyToMessageId: replyMsgId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ },
ParseMode: formatMode,
ReplyMarkup: keyb,
Caption: filterData.FilterReply,
@@ -1187,9 +1231,11 @@ var FiltersEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, filterDa
}
return b.SendVideo(
ctx.Update.Message.Chat.Id,
- filterData.FileID,
+ gotgbot.InputFileByID(filterData.FileID),
&gotgbot.SendVideoOpts{
- ReplyToMessageId: replyMsgId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ },
ParseMode: formatMode,
ReplyMarkup: keyb,
Caption: filterData.FilterReply,
@@ -1198,12 +1244,14 @@ var FiltersEnumFuncMap = map[int]func(b *gotgbot.Bot, ctx *ext.Context, filterDa
},
)
},
- db.VideoNote: func(b *gotgbot.Bot, ctx *ext.Context, filterData db.ChatFilters, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, noFormat, noNotif bool) (*gotgbot.Message, error) {
+ db.VideoNote: func(b *gotgbot.Bot, ctx *ext.Context, filterData db.ChatFilters, keyb *gotgbot.InlineKeyboardMarkup, replyMsgId int64, _, noNotif bool) (*gotgbot.Message, error) {
return b.SendVideoNote(
ctx.Update.Message.Chat.Id,
- filterData.FileID,
+ gotgbot.InputFileByID(filterData.FileID),
&gotgbot.SendVideoNoteOpts{
- ReplyToMessageId: replyMsgId,
+ ReplyParameters: &gotgbot.ReplyParameters{
+ MessageId: replyMsgId,
+ },
ReplyMarkup: keyb,
DisableNotification: noNotif,
MessageThreadId: ctx.Update.Message.MessageThreadId,
diff --git a/app.json b/app.json
index 3ca523ff..2aecabdb 100644
--- a/app.json
+++ b/app.json
@@ -9,44 +9,49 @@
"alita",
"alita_robot"
],
- "repository": "https://github.com/divkix/Alita_Robot",
- "website": "https://divideprojects.com",
+ "repository": "https://github.com/divkideprojects/Alita_Robot",
+ "website": "https://divkix.me",
"success_url": "https://t.me/DivideProjects",
"env": {
"BOT_TOKEN": {
"description": "Your telegram bot token, get from @Botfather in telegram.",
- "required": true,
- "value": ""
+ "required": true
},
- "APP_ID": {
- "description": "Get API_ID from my.telegram.org, used for pyrogram base.",
- "required": true,
- "value": ""
- },
- "API_HASH": {
- "description": "Get API_HASH from my.telegram.org, used for pyrogram base.",
- "required": true,
- "value": ""
+ "BOT_VERSION": {
+ "description": "Version of your bot.",
+ "required": true
},
"DB_URI": {
"description": "Your MongoDB connection string.",
- "required": true,
- "value": ""
+ "required": true
},
"DB_NAME": {
"description": "Your MongoDB database name.",
- "required": true,
- "value": "alita"
+ "required": true
},
"OWNER_ID": {
"description": "Your user ID as an integer.",
- "required": true,
- "value": ""
+ "required": true
},
"MESSAGE_DUMP": {
"description": "Event logs channel where bot will send updates. Starts with -100",
- "required": true,
- "value": ""
+ "required": true
+ },
+ "ENABLED_LOCALES": {
+ "description": "Locales enabled for your bot.",
+ "required": true
+ },
+ "REDIS_ADDRESS": {
+ "description": "Address for your Redis instance.",
+ "required": true
+ },
+ "REDIS_PASSWORD": {
+ "description": "Password for your Redis instance.",
+ "required": true
+ },
+ "USE_WEBHOOKS": {
+ "description": "Whether to use webhooks or not.",
+ "required": true
}
},
"buildpacks": [
@@ -60,4 +65,4 @@
"size": "eco"
}
}
-}
+}
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
index bce6ed8b..745f6901 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,20 +1,25 @@
-version: '3.8'
-
services:
alita:
- image: ghcr.io/divideprojects/alita_robot:latest
+ build:
+ context: .
+ dockerfile: docker/alpine
container_name: alita-robot
restart: always
- environment:
- - BOT_TOKEN
- - BOT_VERSION
- - DB_NAME
- - DB_PASS
- - DB_URI
- - DROP_PENDING_UPDATES
- - ENABLED_LOCALES
- - MESSAGE_DUMP
- - OWNER_ID
- - REDIS_ADDRESS
- - REDIS_PASSWORD
- - REDIS_DB
+ env_file:
+ - .env
+ depends_on:
+ - mongodb
+ - redis
+
+ mongodb:
+ image: mongo:latest
+ restart: always
+ env_file:
+ - .db.env
+ volumes:
+ - ./docker/entrypoint-initdb.d/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
+
+ redis:
+ image: redis:latest
+ restart: always
+ command: redis-server --requirepass redisPassword
diff --git a/docker/alpine b/docker/alpine
index c81fc927..44a32d44 100644
--- a/docker/alpine
+++ b/docker/alpine
@@ -1,5 +1,5 @@
# Build Stage: Build bot using the alpine image
-FROM golang:1.20-alpine AS builder
+FROM golang:alpine AS builder
RUN apk add --no-cache curl wget gnupg git upx
WORKDIR /app
COPY . .
diff --git a/docker/entrypoint-initdb.d/mongo-init.js b/docker/entrypoint-initdb.d/mongo-init.js
new file mode 100644
index 00000000..44ac313d
--- /dev/null
+++ b/docker/entrypoint-initdb.d/mongo-init.js
@@ -0,0 +1,14 @@
+// Switch to the 'alita' database
+db = db.getSiblingDB('alita');
+
+// create a new user
+db.createUser({
+ user: "admin",
+ pwd: "admin",
+ roles: [
+ {
+ role: "readWrite",
+ db: "alita"
+ }
+ ]
+});
diff --git a/go.mod b/go.mod
index 50176449..7a12b2ca 100644
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.19
require (
github.com/PaulSonOfLars/gotg_md2html v0.0.0-20230615075057-63792bdcacf8
- github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.20
+ github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.28
github.com/dgraph-io/ristretto v0.1.1
github.com/dustin/go-humanize v1.0.1
github.com/eko/gocache/lib/v4 v4.1.6
diff --git a/go.sum b/go.sum
index a663ff86..a45ba0a4 100644
--- a/go.sum
+++ b/go.sum
@@ -2,6 +2,8 @@ github.com/PaulSonOfLars/gotg_md2html v0.0.0-20230615075057-63792bdcacf8 h1:Jifk
github.com/PaulSonOfLars/gotg_md2html v0.0.0-20230615075057-63792bdcacf8/go.mod h1:RprvtzpWhKv7APWJQuW4zjG1XhIOPSvfIfvAHAxJaTY=
github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.20 h1:LgJ2DwqvtvvUOMS2q7IdeaLS1olDUQqDZ4GZliQZAPM=
github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.20/go.mod h1:r815fYWTudnU9JhtsJAxUtuV7QrSgKpChJkfTSMFpfg=
+github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.28 h1:3EidAXUUuDBwaRX5881fmpGGv2WPnW9oHwRMlvdQiwU=
+github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.28/go.mod h1:kL1v4iIjlalwm3gCYGvF4NLa3hs+aKEfRkNJvj4aoDU=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
diff --git a/main.go b/main.go
index 9cbfac25..76e50ea3 100644
--- a/main.go
+++ b/main.go
@@ -34,7 +34,7 @@ func main() {
b, err := gotgbot.NewBot(
config.BotToken,
&gotgbot.BotOpts{
- DefaultRequestOpts: &gotgbot.RequestOpts{
+ RequestOpts: &gotgbot.RequestOpts{
APIURL: config.ApiServer,
},
},
@@ -47,19 +47,15 @@ func main() {
alita.InitialChecks(b)
// Create updater and dispatcher.
- updater := ext.NewUpdater(&ext.UpdaterOpts{
- Dispatcher: ext.NewDispatcher(&ext.DispatcherOpts{
- // If an error is returned by a handler, log it and continue going.
- Error: func(b *gotgbot.Bot, ctx *ext.Context, err error) ext.DispatcherAction {
- log.Println("an error occurred while handling update:", err.Error())
- return ext.DispatcherActionNoop
- },
- MaxRoutines: ext.DefaultMaxRoutines,
- }),
+ dispatcher := ext.NewDispatcher(&ext.DispatcherOpts{
+ // If an error is returned by a handler, log it and continue going.
+ Error: func(_ *gotgbot.Bot, _ *ext.Context, err error) ext.DispatcherAction {
+ log.Println("an error occurred while handling update:", err.Error())
+ return ext.DispatcherActionNoop
+ },
+ MaxRoutines: ext.DefaultMaxRoutines,
})
-
- // extract dispatcher from updater
- dispatcher := updater.Dispatcher
+ updater := ext.NewUpdater(dispatcher, nil) // create updater with dispatcher
if _, err = b.DeleteWebhook(nil); err != nil {
log.Fatalf("[Polling] Failed to remove webhook: %v", err)
@@ -70,7 +66,7 @@ func main() {
err = updater.StartPolling(b,
&ext.PollingOpts{
DropPendingUpdates: config.DropPendingUpdates,
- GetUpdatesOpts: gotgbot.GetUpdatesOpts{
+ GetUpdatesOpts: &gotgbot.GetUpdatesOpts{
AllowedUpdates: config.AllowedUpdates,
},
},
diff --git a/sample.db.env b/sample.db.env
new file mode 100644
index 00000000..e69de29b