diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..6deb9a6b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch Package", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "main.go" + } + ] +} \ No newline at end of file diff --git a/commands/stream.go b/commands/stream.go index a559440d..b41fac7c 100644 --- a/commands/stream.go +++ b/commands/stream.go @@ -10,6 +10,7 @@ import ( "github.com/celestix/gotgproto/dispatcher/handlers" "github.com/celestix/gotgproto/dispatcher/handlers/filters" "github.com/celestix/gotgproto/ext" + "github.com/celestix/gotgproto/storage" "github.com/gotd/td/tg" ) @@ -28,13 +29,20 @@ func sendLink(ctx *ext.Context, u *ext.Update) error { return dispatcher.EndGroups } chatId := u.EffectiveChat().GetID() + peer := storage.GetPeerById(config.ValueOf.LogChannelID) + switch storage.EntityType(peer.Type) { + case storage.TypeChat: + return dispatcher.EndGroups + case storage.TypeUser: + return dispatcher.EndGroups + } update, err := ctx.ForwardMessages( chatId, config.ValueOf.LogChannelID, &tg.MessagesForwardMessagesRequest{ FromPeer: &tg.InputPeerChat{ChatID: chatId}, ID: []int{u.EffectiveMessage.ID}, - ToPeer: &tg.InputPeerChannel{ChannelID: config.ValueOf.LogChannelID, AccessHash: 0}, + ToPeer: &tg.InputPeerChannel{ChannelID: config.ValueOf.LogChannelID, AccessHash: peer.AccessHash}, }, ) if err != nil {