(ctx context.Context, api *tg.Client, peerStorage *storage.PeerStorage)
| 144 | } |
| 145 | |
| 146 | func GetLogChannelPeer(ctx context.Context, api *tg.Client, peerStorage *storage.PeerStorage) (*tg.InputChannel, error) { |
| 147 | cachedInputPeer := peerStorage.GetInputPeerById(config.ValueOf.LogChannelID) |
| 148 | |
| 149 | switch peer := cachedInputPeer.(type) { |
| 150 | case *tg.InputPeerEmpty: |
| 151 | break |
| 152 | case *tg.InputPeerChannel: |
| 153 | return &tg.InputChannel{ |
| 154 | ChannelID: peer.ChannelID, |
| 155 | AccessHash: peer.AccessHash, |
| 156 | }, nil |
| 157 | default: |
| 158 | return nil, errors.New("unexpected type of input peer") |
| 159 | } |
| 160 | inputChannel := &tg.InputChannel{ |
| 161 | ChannelID: config.ValueOf.LogChannelID, |
| 162 | } |
| 163 | channels, err := api.ChannelsGetChannels(ctx, []tg.InputChannelClass{inputChannel}) |
| 164 | if err != nil { |
| 165 | return nil, err |
| 166 | } |
| 167 | if len(channels.GetChats()) == 0 { |
| 168 | return nil, errors.New("no channels found") |
| 169 | } |
| 170 | channel, ok := channels.GetChats()[0].(*tg.Channel) |
| 171 | if !ok { |
| 172 | return nil, errors.New("type assertion to *tg.Channel failed") |
| 173 | } |
| 174 | // Bruh, I literally have to call library internal functions at this point |
| 175 | peerStorage.AddPeer(channel.GetID(), channel.AccessHash, storage.TypeChannel, "") |
| 176 | return channel.AsInput(), nil |
| 177 | } |
| 178 | |
| 179 | func ForwardMessages(ctx *ext.Context, fromChatId, toChatId int64, messageID int) (*tg.Updates, error) { |
| 180 | fromPeer := ctx.PeerStorage.GetInputPeerById(fromChatId) |
no outgoing calls
no test coverage detected