AmarnathCJD / gogram

Full-native implementation of MTProto protocol on Golang.
GNU General Public License v3.0
224 stars 44 forks source link

TODO List #162

Open AmarnathCJD opened 3 weeks ago

AmarnathCJD commented 3 weeks ago
AmarnathCJD commented 3 days ago
d, err := client.GetDialogs(&tg.DialogOptions{
    Limit: 500,
})
for _, v := range d {
    switch dx := v.(type) {
    case *tg.DialogObj:
        peer, err := client.GetSendablePeer(dx.Peer)
        if err != nil {
            client.Logger.Error(err)
            continue
        }

        switch peer.(type) {
        case *tg.InputPeerChannel:
            channel, _ := client.GetChannel(peer.(*tg.InputPeerChannel).ChannelID)
            client.Logger.Info(fmt.Sprintf("Channel: %s", channel.Title))
        case *tg.InputPeerChat:
            chat, _ := client.GetChat(peer.(*tg.InputPeerChat).ChatID)
            client.Logger.Info(fmt.Sprintf("Chat: %s", chat.Title))
        }
    }
}