Skip to content

Commit

Permalink
fix(plugin): get access_hash from session storage
Browse files Browse the repository at this point in the history
  • Loading branch information
EverythingSuckz committed Nov 27, 2023
1 parent f499153 commit d805c6d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
10 changes: 9 additions & 1 deletion commands/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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 {
Expand Down

0 comments on commit d805c6d

Please sign in to comment.