Giter Site home page Giter Site logo

amarnathcjd / gogram Goto Github PK

View Code? Open in Web Editor NEW
134.0 6.0 25.0 1.46 MB

Full-native implementation of MTProto protocol on Golang.

License: GNU General Public License v3.0

Go 100.00%
awesome go golang mtproto telegram telegram-api telegram-mtproto botapi tdlib tg

gogram's Introduction

Gogram
Telegram MTProto API Framework for Golang
Homepage Docs Releases Support

GoGram

Light Weight, Fast, Elegant Telegram MTProto API framework in Golang for building Telegram clients and bots.

Status

GoDoc Go Report Card License GitHub stars GitHub forks GitHub issues

package main

import "github.com/amarnathcjd/gogram/telegram"

func main() {
    client, err := telegram.NewClient(&telegram.ClientConfig{
        AppID: 6, AppHash: "<app-hash>",
        // StringSession: "<string-session>",
    })

    client.ConnectBot("<bot-token>") // or client.Login("<phone-number>") for user account
    // client.AuthPrompt() // for console-based interactive auth

    client.AddMessageHandler(telegram.OnNewMessage, func(message *telegram.NewMessage) error {
        if m.IsPrivate() {
            m.Reply("Hello from Gogram!")
        }
    })

    client.Idle() // block main goroutine until client is closed
}

Gogram is a modern, elegant and concurrent MTProto API framework. It enables you to easily interact with the main Telegram API through a user account (custom client) or a bot identity (bot API alternative) using Go.

Support

If you'd like to support Gogram, you can consider:

Key Features

  • Ready: Install Gogram with go get and you are ready to go!
  • Easy: Makes the Telegram API simple and intuitive, while still allowing advanced usages.
  • Elegant: Low-level details are abstracted and re-presented in a more convenient way.
  • Fast: Backed by a powerful and concurrent library, Gogram can handle even the heaviest workloads.
  • Zero Dependencies: No need to install anything else than Gogram itself.
  • Powerful: Full access to Telegram's API to execute any official client action and more.
  • Feature-Rich: Built-in support for file uploading, formatting, custom keyboards, message editing, moderation tools and more.
  • Up-to-date: Gogram is always in sync with the latest Telegram API changes and additions (tl-parser is used to generate the API layer).

Current Layer - 177 (Updated on 2024-04-01)

Installing

go get -u github.com/amarnathcjd/gogram/telegram

Doing Stuff

Sending a Message

client.SendMessage("username", "Hello from Gogram!", &telegram.SendOptions{
	TTL: int32((math.Pow(2, 31) - 1)), //  TTL For OneTimeMedia
})

client.SendDice("username", "🎲")

client.AddMessageHandler("/start", func(m *telegram.Message) error {
    m.Reply("Hello from Gogram!") // m.Respond("<text>")
    return nil
})

Sending Media

client.SendMedia("username", "<file-name>", &telegram.MediaOptions{ // filename/inputmedia,...
    Caption: "Hello from Gogram!",
})

client.SendAlbum("username", []string{"<file-name>", "<file-name>"}, &telegram.MediaOptions{ // Array of filenames/inputmedia,...
    Caption: "Hello from Gogram!",
})

Inline Queries

client.AddInlineHandler("<pattern>", func(iq *telegram.InlineQuery) error {
	builder := iq.Builder()
	builder.Article("<title>", "<description>", "<text>", &telegram.ArticleOptions{
			LinkPreview: true,
	})

	return nil
})

Features TODO

  • Basic MTProto implementation (LAYER 172)
  • Updates handling system + Cache
  • HTML, Markdown Parsing, Friendly Methods
  • Support for Flag2.0, Layer 147
  • WebRTC Calls Support
  • Documentation for all methods
  • Stabilize File Uploading
  • Stabilize File Downloading
  • Secret Chats Support

Known Issues

  • File Uploading/Downloading is not stable
  • MessageMediaPoll, UserFull Decode Fails
  • invokeWithLayer channel missing while bad Salt
  • tcp.io.Reader.Read unstable
  • HTML Parser

Contributing

Gogram is an open-source project and your contribution is very much appreciated. If you'd like to contribute, simply fork the repository, commit your changes and send a pull request. If you have any questions, feel free to ask.

Resources

  • Documentation: (Coming Soon)
  • Support: @rosexchat

License

This library is provided under the terms of the GPL-3.0 License.

gogram's People

Contributors

aiexz avatar amarnathcjd avatar anjanamadu avatar deepsource-autofix[bot] avatar deepsourcebot avatar dropout1337 avatar itzrexmodz avatar jwillp avatar roseloverx avatar xzb-1248 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gogram's Issues

Convenient way

make client.SendM....
to accept username or chat id instead of calling GetSendablePeer

Inconsistant type handling

Describe the bug

A clear and concise description of what the bug is.

Code Information

func StreamFile(m *telegram.NewMessage) error {
	if m.Args() == "" || !m.IsReply() || !m.Message.ReplyTo.
		m.Reply("No file link found. Use <code>/stream filelink</code> command to stream the file from the link or reply to a video file to stream it.")
		return nil
	}
	fmt.Println(filelink)
	return nil
}

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '...'
  3. Scroll down to '...'
  4. See the error related to the type not being properly handled after ReplyToMsg in the AmarnathCJD/gogram library.

Expected behavior

A clear and concise description of what you expected to happen.

The expected behavior is that the ReplyToMsg method in the AmarnathCJD/gogram library should properly handle and display all fields of the replied message. This includes fields beyond the ReplyToMsg ID, such as sender information, message content, timestamp, and any other relevant data associated with the replied message.

Observed behavior

A clear and concise description of what is currently happening.

The current behavior is that after using the ReplyToMsg method, only the ReplyToMsg ID is displayed. Other fields and data associated with the replied message, such as sender information and message content, are not properly handled and displayed. This inconsistency in handling the type after ReplyToMsg limits the ability to access and utilize the complete information of the replied message.

Screenshots

If applicable, add screenshots to help explain your problem.

Screenshot of the type handling issue after ReplyToMsg

Desktop

  • OS: Linux
  • Browser: Safari (latest version)

Additional context

Add any other context about the problem here.

This issue affects the functionality and usability of the AmarnathCJD/gogram library as it prevents users from accessing and utilizing the complete set of fields and data associated with the replied message. It is essential for the library to handle the type properly after ReplyToMsg to ensure consistent behavior and provide access to all relevant information of the replied message.

Bad Guidance in readme

Bug Description

A specific method mentioned in the gogram library's README file is missing in the codebase, causing functional inconsistencies.

To Reproduce

Steps to reproduce the behavior:

  1. Access the relevant section of the README file.
  2. Scroll down and review the provided code snippet.
  3. Notice that the expected method is not present in the library codebase.

Expected Behavior

The expected behavior is for the mentioned method to be available in the gogram library, aligning with the documentation provided in the README file.

Screenshots

If applicable, please attach screenshots or code snippets that help illustrate the issue.

Desktop (Brave - Linux)

  • Operating System: Linux
  • Browser: Brave
  • Version: [e.g., Latest Version]

Additional Context

Additional information regarding the problem:

The method mentioned in the README file is crucial for performing a specific task in the gogram library. However, upon examining the codebase, it is evident that the method is missing, leading to inconsistencies in the library's functionality.

To further understand the issue, I reviewed the provided code snippet in the README file and attempted to locate the corresponding method in the gogram library's source code. Unfortunately, the method is absent, which contradicts the documentation's claim.

This missing method affects the ability to achieve the desired functionality, hampering the intended use of the gogram library in real-world scenarios. As a result, developers relying on this method are unable to leverage its capabilities as described in the README file.

Attached below is an example of the code snippet from the README file, indicating the missing method:

Providing the complete and accurate implementation of the missing method would greatly benefit developers using the gogram library, as it would enable them to leverage the desired functionality seamlessly.

Please let me know if any additional information or clarification is required to address this issue effectively.

BUG with GetDialog function

When I call the Get Dialogs function it generates the following error
[session](panic: sending MessagesGetDialogs: sending packet: marshaling request: value can't be nil)

Code

recreating connection: reqPQ: nonce mismatch

Example

log.Printf("init...\n")
client, _ := telegram.NewClient(telegram.ClientConfig{
	AppID:   int32(apiId),
	AppHash: apiHash,
})
client.Connect()
client.ImportRawSession(session.AuthKey, session.AuthKeyHash, session.Addr, int(session.DcID), int32(apiId))
log.Printf("init end...\n")
client.GetMe()

Logs

2023/05/11 17:04:06 call getSignInUser...
2023/05/11 17:04:06 init...
2023/05/11 17:04:06 gogram - mtproto - Info - Connecting to [149.154.167.91:443] - <TCPFull> ...
2023/05/11 17:04:06 gogram - mtproto - Info - Connection to [149.154.167.91:443] - <TCPFull> established
2023/05/11 17:04:13 gogram - mtproto - Error - reconnecting error: recreating connection: reqPQ: nonce mismatch
2023/05/11 17:05:18 init end...
2023/05/11 17:06:23 gogram - mtproto - Error - reconnecting error: recreating connection: reqPQ: nonce mismatch

got invalid response type: *objects.ResPQ
/Users/feit/Project/telegram-transport/vendor/github.com/amarnathcjd/gogram/telegram/methods_gen.go:11159 (0x12d6044)
        (*Client).UsersGetFullUser: panic("got invalid response type: " + reflect.TypeOf(responseData).String())
/Users/feit/Project/telegram-transport/vendor/github.com/amarnathcjd/gogram/telegram/users.go:11 (0x12dd8ca)
        (*Client).GetMe: resp, err := c.UsersGetFullUser(&InputUserSelf{})
/Users/feit/Project/telegram-transport/src/mtproto/api.go:53 (0x12f4445)
        TGetMe: user, err := client.GetMe()
/Users/feit/Project/telegram-transport/src/service/client.go:15 (0x12f4b93)
        GetSignInUser: user, err := mtproto.TGetMe(tag, apiId, apiHash, proxyAddress, proxyUsername, proxyPassword)
/Users/feit/Project/telegram-transport/src/controller/client.go:40 (0x1414e5c)
        GetSignInUser: result := service.GetSignInUser(tag, apiId, apiHash, proxyAddress, proxyUsername, proxyPassword)
/Users/feit/Project/telegram-transport/vendor/github.com/gin-gonic/gin/context.go:174 (0x140ea01)
        (*Context).Next: c.handlers[c.index](c)
/Users/feit/Project/telegram-transport/vendor/github.com/gin-gonic/gin/recovery.go:102 (0x140e9ec)
        CustomRecoveryWithWriter.func1: c.Next()
/Users/feit/Project/telegram-transport/vendor/github.com/gin-gonic/gin/context.go:174 (0x140db26)
        (*Context).Next: c.handlers[c.index](c)
/Users/feit/Project/telegram-transport/vendor/github.com/gin-gonic/gin/logger.go:240 (0x140db09)
        LoggerWithConfig.func1: c.Next()
/Users/feit/Project/telegram-transport/vendor/github.com/gin-gonic/gin/context.go:174 (0x140cbaa)
        (*Context).Next: c.handlers[c.index](c)
/Users/feit/Project/telegram-transport/vendor/github.com/gin-gonic/gin/gin.go:620 (0x140c831)
        (*Engine).handleHTTPRequest: c.Next()
/Users/feit/Project/telegram-transport/vendor/github.com/gin-gonic/gin/gin.go:576 (0x140c4dc)
        (*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/usr/local/go/src/net/http/server.go:2936 (0x12a4b35)
        serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/local/go/src/net/http/server.go:1995 (0x12a1451)
        (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/local/go/src/runtime/asm_amd64.s:1598 (0x1066920)
        goexit: BYTE    $0x90   // NOP

What is causing the program to crash?Judging from the log printing time, there is a long time of no response in the middle.

Need a little more help

inviteLinkInfo, err := client.MessagesCheckChatInvite(inviteLink_ID)
obj, _:=inviteLinkInfo.(*telegram.ChatInviteObj) //field Participants []telegram.User
obj.Participants //How to get the actual content, not the address

update_afterjoin,_:=client.MessagesImportChatInvite(inviteLink_ID)
type UpdatesObj struct {
Updates []Update
Users []User
Chats []Chat
Date int32
Seq int32
}
update_afterjoin.(*telegram.UpdatesObj).Chats
//How to get the actual content, not the address
[0xc0082787e0 0xc008278a80 0xc008278d20]

mobile number login (Windows OS Only)

reading error: processing response: msg_seqno too high (similarly, there is a message with a higher msg_id but with either a lower or an equal and odd seqno) (code 33)

Entity UnboundError

2023/01/28 17:17:35 MTProto [INFO] Disconnecting Borrowed Sender from 91.108.56.151:443/TcpFull...
sending MessagesSendMedia: ENTITY_BOUNDS_INVALID (code 400)

Most prolly its cause of empty html tags. Make a way in lib to handle this internally

Issue in handling multiple users if multiple ids passed to User parameter in AddMessageHandle

Bug Description

The gogram library exhibits incorrect behavior when multiple user IDs are passed to the Users field in the AddMessageHandler function. While the code works flawlessly when a single user ID is provided, it fails to handle multiple user IDs properly.

When multiple user IDs are specified in the Users field, the message handler is expected to be triggered for each user ID individually. However, in the current implementation, the message handler fails to execute for any of the provided user IDs.

This bug severely limits the functionality of the gogram library in scenarios where message handlers need to be registered for multiple users simultaneously.

To Reproduce

Steps to reproduce the behavior:

  1. Initialize the bot using the following code:
package src

import (
	"fmt"
	"log"

	"github.com/amarnathcjd/gogram/telegram"
)

func InitBot() *telegram.Client {
	log.Println("Initializing bot...")
	client, _ := telegram.NewClient(telegram.ClientConfig{
		AppID:    Envars.AppId,
		AppHash:  Envars.AppHash,
		LogLevel: telegram.LogInfo,
		Session:  "./session.session",
	})

	if err := client.Connect(); err != nil {
		panic(err)
	}
	if err := client.LoginBot(Envars.Token); err != nil {
		panic(err)
	}
	client.AddMessageHandler("/text", AuthChatHandler, &telegram.Filters{Users: Envars.Devs})
	return client
}
  1. Pass multiple user IDs to the Users field in the AddMessageHandler function, as shown below:
client.AddMessageHandler("/text", AuthChatHandler, &telegram.Filters{Users: []int{123, 456, 789}})

1, Trigger the message handler by sending a relevant message.

  1. Observe that the code fails to handle multiple user IDs correctly, and the message handler does not execute for any of the provided user IDs.

Expected Behavior

The expected behavior is that the gogram library should handle multiple user IDs properly in the AddMessageHandler function. Specifically, the message handler should be triggered individually for each user ID provided in the Users field.

Actual Behavior

Contrary to expectations, the current implementation of the gogram library fails to handle multiple user IDs correctly. When multiple user IDs are specified, the message handler does not execute for any of the provided user IDs.

Environment Details

  1. Operating System: Linux
  2. Go Version: 1.20

Additional Information

The version of the gogram library being used: github.com/amarnathcjd/gogram v0.0.0-20230616162607-84be75d00aa5

Steps Taken to Resolve the Issue

I have examined the code implementation thoroughly and ensured that the user IDs are correctly provided to the AddMessageHandler function. Additionally, I have reviewed the available documentation and examples for the gogram library but couldn't find any specific guidance on handling multiple user IDs in the AddMessageHandler function.

Docs

create a well described documentation please like telethon and pyrogram or madeline proto in php

question

Possible to create a channel and update it?

LogDebug rip

		AppID:    int(variables.Envs.APP_ID),
		AppHash:  variables.Envs.APP_HASH,
		LogLevel: telegram.LogDebug,
	})

LogDebug deosnt seem to do anything still logs are logges as info

Video MisFormatted

Sometimes the uploaded video is misformatted or audio ripped off from it or has invalid duration

Some bugs, Peer bot

I have some problems

The first problem, I don't know what the problem is, I have pictures 1 and 2
IMG_20230511_063633_973
IMG_20230511_063630_920
When the program is run and displayed like the first picture, the bot does not run and does not respond, but when it appears like the second picture, the bot runs normally

The second problem is that the bot is already running, I try to send a chat to the user who has communicated with the bot, the results are normal, but when I kill the program with **Ctrl + c**, then try to send a chat with the user, I get an error peer no user with id 6281818110 or missing from cache, I am confused about how it works until it can be like that, is it true that as a bot you have to save the peer, I think the bot can interact forever when it is /start and not blocked by the user.

then I tried to use EnableCache: true
the problem is solved but a new problem like this appears Error while moving temporary file to cache file: rename /tmp/cache-1348554052.tmp cache.journal: invalid cross-device link worse I can not do interrupt or Ctrl + c so every time I want to stop the program I have to **Ctrl + z** then run kill -9 pid very tiring, this problem does not always occur, but if it happens I have to receive chat or interaction from users in order to send chat to them again.
IMG_20230511_064828_141

Error start bot: sending MessagesStartBot: [BOT_INVALID] This is not a valid bot. (code 400)

...
me, _ := client.GetMe()
inpuser := &telegram.InputUserObj{UserID: int64(5014831088), AccessHash: me.AccessHash}
inppeer := &telegram.InputPeerUser{UserID: int64(5014831088), AccessHash: me.AccessHash}

updates, err := client.MessagesStartBot(inpuser, inppeer, int64(23232323), "mci_EiqcN9duktnKe87")

if err != nil {
fmt.Printf("Error start bot: %v\n\n", err)
}
...

Result:
Error start bot: sending MessagesStartBot: [BOT_INVALID] This is not a valid bot. (code 400)

MessageMediaPoll Fails to Decode

2024/03/01 17:28:04 gogram - mtproto - Error - decoding unknown object: decoding predicted object: 
parsing gzipped object: 
decoding predicted object:
decode registered object *telegram.UpdatesObj: 
decode field 'Updates': 
decode interface: decode registered object *telegram.UpdateNewChannelMessage: 
decode field 'Message': 
decode interface: decode registered object *telegram.MessageObj: 
decode field 'Media': 
decode interface: 
decode registered object *telegram.MessageMediaPoll: 
decode field 'Poll': 
decode field 'Question': 
some of void bytes doesn't equal zero: []byte{0x67, 0x79, 0x0}

add Callback function in Login

`type Callback func() (string, error)

func (c *Client) Login(phoneNumber string, callback Callback, options ...*LoginOptions) (bool, error) {
// ......

if opts.Code == "" {
	hash, e := c.SendCode(phoneNumber)
	if e != nil {
		return false, e
	}
	opts.CodeHash = hash
	for {
		// use call back to get code  Phone code
		codeInput, err := callback()
		if err != nil {
			return false, err
		}

		// ......
	}
        for {
	        // use call back to get password  Two-steps verification
	       passwordInput, err := callback()
		if err != nil {
			return false, err
		}
        }
}

// ......

}
`
I'm using the ui form to log in, could add a callback to send a code so I can interact with the ui?

Handle error

Handle error when length = 0


panic: runtime error: index out of range [-1]

goroutine 1 [running]:
github.com/amarnathcjd/gogram/internal/aes_ige.pkcs5UnPadding(...)
        /pkg/mod/github.com/amarnathcjd/[email protected]/internal/aes_ige/aes_common.go:41
github.com/amarnathcjd/gogram/internal/aes_ige.DecryptAES({0xc00012e000, 0x0, 0x200}, {0x869011, 0x20})
        /pkg/mod/github.com/amarnathcjd/[email protected]/internal/aes_ige/aes_common.go:29 +0x1b7
github.com/amarnathcjd/gogram/telegram.(*CACHE).loadFromFile(0xc00009b530)
        /pkg/mod/github.com/amarnathcjd/[email protected]/telegram/cache.go:72 +0x48
github.com/amarnathcjd/gogram/telegram.NewCache()
        /pkg/mod/github.com/amarnathcjd/[email protected]/telegram/cache.go:98 +0x229
github.com/amarnathcjd/gogram/telegram.init()
        /pkg/mod/github.com/amarnathcjd/[email protected]/telegram/cache.go:83 +0x1d


func pkcs5UnPadding(origData []byte) []byte {
length := len(origData)
unpadding := int(origData[length-1])
return origData[:(length - unpadding)]

Bot not responded

Why does the bot often not respond, but I don't find anything in the terminal, and I have to restart the program so that the bot can respond, and it happens repeatedly which requires restarting the program, what is the cause?, I don't find any signs of error in the console.

decoding unknown object

Sorry, one more question. This session works fine but an error occurs while getting my own user.

	session := redis.RedisGet("telegram:client:" + phone)
	client, err := telegram.NewClient(telegram.ClientConfig{
		AppID:         int32(telegramConfig.AppId),
		AppHash:       telegramConfig.AppHash,
		AppVersion:    telegramConfig.AppVersion,
		DeviceModel:   telegramConfig.DeviceModel,
		SystemVersion: telegramConfig.SystemVersion,
		LogLevel:      telegram.LogDebug,
		LangCode:      "en",
		StringSession: session,
	})
	client.Connect()
	user, err := client.GetMe()

2024/03/13 22:29:21 gogram - cache - debug - initialized cache (gogram_KVwV.db) successfully
2024/03/13 22:29:21 gogram - mtproto - debug - importing Auth from stringSession...
2024/03/13 22:29:21 gogram - mtproto - info - Connecting to [91.108.56.151:443] - <TCPFull> ...
2024/03/13 22:29:21 gogram - mtproto - info - Connection to [91.108.56.151:443] - <TCPFull> established
2024/03/13 22:29:21 gogram - client - debug - sending initial invokeWithLayer request
2024/03/13 22:29:21 gogram - mtproto - debug - session configs changed, resending request
2024/03/13 22:29:25 gogram - mtproto - debug - RPC response: *telegram.Config
2024/03/13 22:29:25 gogram - mtproto - debug - RPC response: *telegram.UpdatesState
2024/03/13 22:29:25 gogram - mtproto - info - Connecting to [91.108.56.151:443] - <TCPFull> ...
2024/03/13 22:29:25 gogram - mtproto - info - Connection to [91.108.56.151:443] - <TCPFull> established
2024/03/13 22:29:25 gogram - client - debug - sending initial invokeWithLayer request
2024/03/13 22:29:25 gogram - mtproto - debug - RPC response: *telegram.Config
2024/03/13 22:29:25 gogram - mtproto - error - decoding unknown object: decoding predicted object: decode registered object *objects.RpcResult: decode field 'Obj': decode interface: decode registered object *telegram.UsersUserFull: decode field 'FullUser': decode field 'Settings': invalid crc code: 0x0, want: 0xa518110d
2024/03/13 22:29:25 gogram - mtproto - error - decoding unknown object: decoding predicted object: decode registered object *objects.RpcResult: decode field 'Obj': decode interface: decode registered object *telegram.UsersUserFull: decode field 'FullUser': decode field 'Settings': invalid crc code: 0x0, want: 0xa518110d
2024/03/13 22:29:26 gogram - mtproto - error - decoding unknown object: decoding predicted object: decode registered object *objects.RpcResult: decode field 'Obj': decode interface: decode registered object *telegram.UsersUserFull: decode field 'FullUser': decode field 'Settings': invalid crc code: 0x0, want: 0xa518110d
2024/03/13 22:29:26 gogram - mtproto - error - decoding unknown object: decoding predicted object: decode registered object *objects.RpcResult: decode field 'Obj': decode interface: decode registered object *telegram.UsersUserFull: decode field 'FullUser': decode field 'Settings': invalid crc code: 0x0, want: 0xa518110d
2024/03/13 22:29:26 gogram - mtproto - error - decoding unknown object: decoding predicted object: decode registered object *objects.RpcResult: decode field 'Obj': decode interface: decode registered object *telegram.UsersUserFull: decode field 'FullUser': decode field 'Settings': invalid crc code: 0x0, want: 0xa518110d
2024/03/13 22:29:26 gogram - mtproto - error - decoding unknown object: decoding predicted object: decode registered object *objects.RpcResult: decode field 'Obj': decode interface: decode registered object *telegram.UsersUserFull: decode field 'FullUser': decode field 'Settings': invalid crc code: 0x0, want: 0xa518110d
2024/03/13 22:29:26 gogram - mtproto - error - decoding unknown object: decoding predicted object: decode registered object *objects.RpcResult: decode field 'Obj': decode interface: decode registered object *telegram.UsersUserFull: decode field 'FullUser': decode field 'Settings': invalid crc code: 0x0, want: 0xa518110d
2024/03/13 22:29:28 gogram - mtproto - error - decoding unknown object: decoding predicted object: decode registered object *objects.RpcResult: decode field 'Obj': decode interface: decode registered object *telegram.UsersUserFull: decode field 'FullUser': decode field 'Settings': invalid crc code: 0x0, want: 0xa518110d
2024/03/13 22:29:28 gogram - mtproto - error - decoding unknown object: decoding predicted object: decode registered object *objects.RpcResult: decode field 'Obj': decode interface: decode registered object *telegram.UsersUserFull: decode field 'FullUser': decode field 'Settings': invalid crc code: 0x0, want: 0xa518110d
2024/03/13 22:29:28 gogram - mtproto - error - decoding unknown object: decoding predicted object: decode registered object *objects.RpcResult: decode field 'Obj': decode interface: decode registered object *telegram.UsersUserFull: decode field 'FullUser': decode field 'Settings': invalid crc code: 0x0, want: 0xa518110d
2024/03/13 22:29:28 gogram - mtproto - error - decoding unknown object: decoding predicted object: decode registered object *objects.RpcResult: decode field 'Obj': decode interface: decode registered object *telegram.UsersUserFull: decode field 'FullUser': decode field 'Settings': invalid crc code: 0x0, want: 0xa518110d
2024/03/13 22:29:29 gogram - mtproto - error - decoding unknown object: decoding predicted object: decode registered object *objects.RpcResult: decode field 'Obj': decode interface: decode registered object *telegram.UsersUserFull: decode field 'FullUser': decode field 'Settings': invalid crc code: 0x0, want: 0xa518110d
2024/03/13 22:29:35 gogram - mtproto - error - decoding unknown object: decoding predicted object: decode registered object *objects.RpcResult: decode field 'Obj': decode interface: decode registered object *telegram.UsersUserFull: decode field 'FullUser': decode field 'Settings': invalid crc code: 0x0, want: 0xa518110d

About sending messages

type ChatObj struct {
Creator bool tl:"flag:0,encoded_in_bitflags"
Left bool tl:"flag:2,encoded_in_bitflags"
Deactivated bool tl:"flag:5,encoded_in_bitflags"
CallActive bool tl:"flag:23,encoded_in_bitflags"
CallNotEmpty bool tl:"flag:24,encoded_in_bitflags"
Noforwards bool tl:"flag:25,encoded_in_bitflags"
ID int64
Title string
Photo ChatPhoto
ParticipantsCount int32
Date int32
Version int32
MigratedTo InputChannel tl:"flag:6"
AdminRights *ChatAdminRights tl:"flag:14"
DefaultBannedRights *ChatBannedRights tl:"flag:18"
}
if c, ok := v.(*telegram.ChatObj); ok
_, err := client.SendMessage(c.ID, "123") //there is no peer with id
_, err := client.SendMessage(c.Title, "123") //MessagesSendMessage: [CHAT_WRITE_FORBIDDEN] You can't write in this chat.
Sending to users is no problem, but how to send to groups
if c, ok := v.(*telegram.UserObj); ok {
_, err := client.SendMessage(c.Username, "123") //ok

sending MessagesGetBotCallbackAnswer: [DATA_INVALID] Encrypted data invalid. (code 400)

...
client.AddMessageHandler(telegram.OnNewMessage, func(message *telegram.NewMessage) error {
    fmt.Printf("Message-%d: %v\n---------\n\n", message.ID, message.Marshal())
    switch message.Sender.ID {
        case 5014831088:
            callbackAnswer, err := message.Click("Q2hlY2s=")
            if err != nil {
                fmt.Printf("MessID_%d_Error callbackAnswer: %v\n\n", message.ID, err)
            }
    }
...

Result:

Message-816: {
  "Out": false,
  "Mentioned": false,
  "MediaUnread": false,
  "Silent": false,
  "Post": false,
  "FromScheduled": false,
  "Legacy": false,
  "EditHide": false,
  "Pinned": false,
  "Noforwards": false,
  "InvertMedia": false,
  "ID": 816,
  "FromID": null,
  "PeerID": {
    "UserID": 5014831088
  },
  "SavedPeerID": null,
  "FwdFrom": null,
  "ViaBotID": 0,
  "ReplyTo": null,
  "Date": 1705569156,
  "Message": "Check in:",
  "Media": null,
  "ReplyMarkup": {
    "Rows": [
      {
        "Buttons": [
          {
            "Text": "❌ Exchange",
            "URL": "https://t.me/Exchange_main"
          }
        ]
      },
      {
        "Buttons": [
          {
            "RequiresPassword": false,
            "Text": "🔍 Проверить подписку",
            "Data": "Q2hlY2s="
          }
        ]
      },
      {
        "Buttons": [
          {
            "RequiresPassword": false,
            "Text": "‹ Назад",
            "Data": "U3ViQmFjaw=="
          }
        ]
      }
    ]
  },
  "Entities": [
    {
      "Offset": 0,
      "Length": 31
    }
  ],
  "Views": 0,
  "Forwards": 0,
  "Replies": null,
  "EditDate": 0,
  "PostAuthor": "",
  "GroupedID": 0,
  "Reactions": null,
  "RestrictionReason": null,
  "TtlPeriod": 0
}
---------

MessID_816_Error callbackAnswer: sending MessagesGetBotCallbackAnswer: [DATA_INVALID] Encrypted data invalid. (code 400)

How to use message.Click correctly?

Escape space in phone number if it has spaces in between?

Enter phone number (with country code) or bot token: +91 xxxx xxxxx
panic: sending AuthSendCode: [PHONE_NUMBER_INVALID] The phone number is invalid. (code 400)

goroutine 1 [running]:
main.main()
        /media/tamilvip007/DISK :)/VS/SpotifyApi/main.go:26 +0x17f
exit status 2

Hold the loop

panic: runtime error: index out of range [1] with length 1

goroutine 65 [running]:
AnimeUploader/plugins.CheckAnimeUpdate()
        D:/GoUploader/plugins/cron.go:29 +0x1b8
created by main.main
        D:/GoUploader/main.go:9 +0x2a

hold the mail loop instead of exiting if panicked

Update layer scheme

Can you you update api layer, because I cannot login as user, the error is panic: sending AuthSentCode: [UPDATE_APP_LOGIN] this layer no longer supports logging in, please update your app (code 406), maybe can you tell me how to update the layer, I will update it

no channel with id ########## or missing from cache

I can't receive messages, no id found.

dialogs, err := client.GetDialogs()
if err != nil {
	panic(err)
}
for _, dialog := range dialogs {
	switch d := dialog.(type) {
	case *telegram.DialogObj:
		messages, err := client.GetMessages(d.Peer)
		if err != nil {
			panic(err)
		}
		for _, msg := range messages {
			fmt.Println("ID:", msg.ID)
		}
	}
}

panic: no channel with id ########## or missing from cache

DownloadMedia function downloads only 512kb of file

I would like to report a bug in the DownloadMedia function of gogram, the Telegram MTProto library. Currently, the function is not functioning as expected, as it only downloads a maximum of 512kb of the file instead of the entire file.

Expected Behavior:
When utilizing the DownloadMedia function, I anticipate that it will download the complete file without any limitations on the file size.

Actual Behavior:
However, the function seems to be limited to downloading only 512kb of the file, regardless of the file's actual size. This behavior prevents users from retrieving the complete file content.

Steps to Reproduce:
To reproduce the issue, follow these steps:

  1. Initialize the gogram library and establish a connection to the Telegram API.
  2. Use the DownloadMedia function to download a file larger than 512kb.
  3. Observe that the function only retrieves 512kb of the file, leaving the remaining content inaccessible.

Expected Output:
The DownloadMedia function should be able to download the entire file, regardless of its size. Users should be able to retrieve the complete content of the requested media.

Additional Information:

  • Version of gogram library: idk
  • Operating System: Windows 10 Pro 64-bit (10.0, Build 19045) (19041.vb_release.191206-1406)

This issue significantly affects users who rely on the DownloadMedia function to retrieve files from Telegram. It would be greatly appreciated if the bug could be addressed, allowing for seamless downloading of files of any size.

Please let me know if any further information or clarification is needed.

out of memory, program crash

I'm sure the memory is enough

msg := make([]byte, int(size))

I checked "size" by adding logs. Under abnormal circumstances, "size" is 3690178031.

2024/03/15 06:20:31 [856 2058362835] call sendCode...
2024/03/15 06:20:31 gogram - mtproto - debug - RPC response: *objects.RpcError
2024/03/15 06:20:31 gogram - client - debug - Exporting string session...
2024/03/15 06:20:31 [856 2058362835] call sendCode error: sending AuthSendCode: [API_ID_INVALID] API ID invalid. (code 400)
[GIN] 2024/03/15 - 06:20:31 | 200 |   70.939807ms |   43.154.54.252 | POST     "/telegram-transport/v1/client/sendCode"
2024/03/15 06:20:39 gogram - mtproto - debug - network is not stable, reconnecting to [91.108.56.151:443] - <TCPFull> ...
fatal error: runtime: out of memory

runtime stack:
runtime.throw({0xa256ae?, 0x203037?})
	/usr/local/go/src/runtime/panic.go:1023 +0x5c fp=0x7fff2be68050 sp=0x7fff2be68020 pc=0x4384dc
runtime.sysMapOS(0xc000800000, 0xdc000000)
	/usr/local/go/src/runtime/mem_linux.go:167 +0x11b fp=0x7fff2be68090 sp=0x7fff2be68050 pc=0x41883b
runtime.sysMap(0xc000800000, 0xdc000000, 0xfa8ac8?)
	/usr/local/go/src/runtime/mem.go:155 +0x34 fp=0x7fff2be680b0 sp=0x7fff2be68090 pc=0x4182b4
runtime.(*mheap).grow(0xf988c0, 0x6df9e?)
	/usr/local/go/src/runtime/mheap.go:1534 +0x236 fp=0x7fff2be68120 sp=0x7fff2be680b0 pc=0x42aff6
runtime.(*mheap).allocSpan(0xf988c0, 0x6df9e, 0x0, 0x1)
	/usr/local/go/src/runtime/mheap.go:1246 +0x1b0 fp=0x7fff2be681c0 sp=0x7fff2be68120 pc=0x42a6d0
runtime.(*mheap).alloc.func1()
	/usr/local/go/src/runtime/mheap.go:964 +0x5c fp=0x7fff2be68208 sp=0x7fff2be681c0 pc=0x42a17c
runtime.systemstack(0x46fbdf)
	/usr/local/go/src/runtime/asm_amd64.s:509 +0x4a fp=0x7fff2be68218 sp=0x7fff2be68208 pc=0x46b72a

goroutine 52 gp=0xc0000b3880 m=0 mp=0xf8f560 [running]:
runtime.systemstack_switch()
	/usr/local/go/src/runtime/asm_amd64.s:474 +0x8 fp=0xc000019c30 sp=0xc000019c20 pc=0x46b6c8
runtime.(*mheap).alloc(0xdbf3c000?, 0x6df9e?, 0x2?)
	/usr/local/go/src/runtime/mheap.go:958 +0x5b fp=0xc000019c78 sp=0xc000019c30 pc=0x42a0db
runtime.(*mcache).allocLarge(0x4c3700?, 0xdbf3a5ef, 0x1?)
	/usr/local/go/src/runtime/mcache.go:234 +0x85 fp=0xc000019cc0 sp=0xc000019c78 pc=0x417385
runtime.mallocgc(0xdbf3a5ef, 0x8c8c60, 0x1)
	/usr/local/go/src/runtime/malloc.go:1165 +0x597 fp=0xc000019d48 sp=0xc000019cc0 pc=0x40e3d7
runtime.makeslice(0xc0000acc60?, 0xc00025cb68?, 0x4?)
	/usr/local/go/src/runtime/slice.go:107 +0x49 fp=0xc000019d70 sp=0xc000019d48 pc=0x451169
github.com/amarnathcjd/gogram/internal/mode.(*intermediate).ReadMsg(0xc00003e780)
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/internal/mode/intermediate.go:49 +0x85 fp=0xc000019df0 sp=0xc000019d70 pc=0x7d0ae5
github.com/amarnathcjd/gogram/internal/transport.(*transport).ReadMsg(0xc00046f650)
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/internal/transport/transport.go:83 +0x2b fp=0xc000019e78 sp=0xc000019df0 pc=0x7d3f8b
github.com/amarnathcjd/gogram.(*MTProto).readMsg(0xc00031e6c0)
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:469 +0x34 fp=0xc000019ef8 sp=0xc000019e78 pc=0x7d9334
github.com/amarnathcjd/gogram.(*MTProto).startReadingResponses.func1()
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:416 +0xc5 fp=0xc000019fe0 sp=0xc000019ef8 pc=0x7d8be5
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000019fe8 sp=0xc000019fe0 pc=0x46d561
created by github.com/amarnathcjd/gogram.(*MTProto).startReadingResponses in goroutine 25
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:405 +0x90

goroutine 1 gp=0xc0000061c0 m=nil [IO wait, 2 minutes]:
runtime.gopark(0xc000050008?, 0xc000029ad8?, 0x31?, 0x79?, 0x2000?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc000029a58 sp=0xc000029a38 pc=0x43b3ce
runtime.netpollblock(0xc000029af0?, 0x405526?, 0x0?)
	/usr/local/go/src/runtime/netpoll.go:573 +0xf7 fp=0xc000029a90 sp=0xc000029a58 pc=0x434297
internal/poll.runtime_pollWait(0x7f589ee43e70, 0x72)
	/usr/local/go/src/runtime/netpoll.go:345 +0x85 fp=0xc000029ab0 sp=0xc000029a90 pc=0x467fe5
internal/poll.(*pollDesc).wait(0x3?, 0xf?, 0x0)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:84 +0x27 fp=0xc000029ad8 sp=0xc000029ab0 pc=0x4c3267
internal/poll.(*pollDesc).waitRead(...)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Accept(0xc00042cc00)
	/usr/local/go/src/internal/poll/fd_unix.go:611 +0x2ac fp=0xc000029b80 sp=0xc000029ad8 pc=0x4c4acc
net.(*netFD).accept(0xc00042cc00)
	/usr/local/go/src/net/fd_unix.go:172 +0x29 fp=0xc000029c38 sp=0xc000029b80 pc=0x572229
net.(*TCPListener).accept(0xc00042f540)
	/usr/local/go/src/net/tcpsock_posix.go:159 +0x1e fp=0xc000029c60 sp=0xc000029c38 pc=0x583b7e
net.(*TCPListener).Accept(0xc00042f540)
	/usr/local/go/src/net/tcpsock.go:327 +0x30 fp=0xc000029c90 sp=0xc000029c60 pc=0x582ed0
net/http.(*onceCloseListener).Accept(0xc00011e1b0?)
	<autogenerated>:1 +0x24 fp=0xc000029ca8 sp=0xc000029c90 pc=0x6733c4
net/http.(*Server).Serve(0xc000318ff0, {0xbf02b0, 0xc00042f540})
	/usr/local/go/src/net/http/server.go:3255 +0x33e fp=0xc000029dd8 sp=0xc000029ca8 pc=0x65591e
net/http.(*Server).ListenAndServe(0xc000318ff0)
	/usr/local/go/src/net/http/server.go:3184 +0x71 fp=0xc000029e08 sp=0xc000029dd8 pc=0x6555b1
net/http.ListenAndServe(...)
	/usr/local/go/src/net/http/server.go:3438
github.com/gin-gonic/gin.(*Engine).Run(0xc0000eb860, {0xc0002b7ee8, 0x1, 0x1})
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/gin-gonic/gin/gin.go:386 +0x1f1 fp=0xc000029ea8 sp=0xc000029e08 pc=0x7b39b1
wind.com/feit-transport/src/controller.InitRouter(0xc0000eb860)
	/Volumes/wind_ssd/project/go-project/feit-transport/src/controller/router.go:38 +0x865 fp=0xc000029f08 sp=0xc000029ea8 pc=0x866245
main.main()
	/Volumes/wind_ssd/project/go-project/feit-transport/src/main.go:18 +0xd4 fp=0xc000029f50 sp=0xc000029f08 pc=0x8663b4
runtime.main()
	/usr/local/go/src/runtime/proc.go:271 +0x29d fp=0xc000029fe0 sp=0xc000029f50 pc=0x43af9d
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000029fe8 sp=0xc000029fe0 pc=0x46d561

goroutine 2 gp=0xc000006700 m=nil [force gc (idle), 2 minutes]:
runtime.gopark(0x239efeaa4ed?, 0x0?, 0x0?, 0x0?, 0x0?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc000062fa8 sp=0xc000062f88 pc=0x43b3ce
runtime.goparkunlock(...)
	/usr/local/go/src/runtime/proc.go:408
runtime.forcegchelper()
	/usr/local/go/src/runtime/proc.go:326 +0xb3 fp=0xc000062fe0 sp=0xc000062fa8 pc=0x43b253
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000062fe8 sp=0xc000062fe0 pc=0x46d561
created by runtime.init.6 in goroutine 1
	/usr/local/go/src/runtime/proc.go:314 +0x1a

goroutine 3 gp=0xc000006c40 m=nil [GC sweep wait]:
runtime.gopark(0x1?, 0x0?, 0x0?, 0x0?, 0x0?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc000063780 sp=0xc000063760 pc=0x43b3ce
runtime.goparkunlock(...)
	/usr/local/go/src/runtime/proc.go:408
runtime.bgsweep(0xc00007a000)
	/usr/local/go/src/runtime/mgcsweep.go:318 +0xdf fp=0xc0000637c8 sp=0xc000063780 pc=0x426bbf
runtime.gcenable.gowrap1()
	/usr/local/go/src/runtime/mgc.go:203 +0x25 fp=0xc0000637e0 sp=0xc0000637c8 pc=0x41b4c5
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc0000637e8 sp=0xc0000637e0 pc=0x46d561
created by runtime.gcenable in goroutine 1
	/usr/local/go/src/runtime/mgc.go:203 +0x66

goroutine 4 gp=0xc000006e00 m=nil [GC scavenge wait]:
runtime.gopark(0x12a3c017?, 0x1296c545?, 0x0?, 0x0?, 0x0?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc000063f78 sp=0xc000063f58 pc=0x43b3ce
runtime.goparkunlock(...)
	/usr/local/go/src/runtime/proc.go:408
runtime.(*scavengerState).park(0xf8dc20)
	/usr/local/go/src/runtime/mgcscavenge.go:425 +0x49 fp=0xc000063fa8 sp=0xc000063f78 pc=0x424569
runtime.bgscavenge(0xc00007a000)
	/usr/local/go/src/runtime/mgcscavenge.go:658 +0x59 fp=0xc000063fc8 sp=0xc000063fa8 pc=0x424b19
runtime.gcenable.gowrap2()
	/usr/local/go/src/runtime/mgc.go:204 +0x25 fp=0xc000063fe0 sp=0xc000063fc8 pc=0x41b465
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000063fe8 sp=0xc000063fe0 pc=0x46d561
created by runtime.gcenable in goroutine 1
	/usr/local/go/src/runtime/mgc.go:204 +0xa5

goroutine 17 gp=0xc0000b2000 m=nil [finalizer wait, 23 minutes]:
runtime.gopark(0xc000062660?, 0x423a3c?, 0x0?, 0x13?, 0x550011?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc000062620 sp=0xc000062600 pc=0x43b3ce
runtime.runfinq()
	/usr/local/go/src/runtime/mfinal.go:194 +0x107 fp=0xc0000627e0 sp=0xc000062620 pc=0x41a507
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc0000627e8 sp=0xc0000627e0 pc=0x46d561
created by runtime.createfing in goroutine 1
	/usr/local/go/src/runtime/mfinal.go:164 +0x3d

goroutine 18 gp=0xc0000b3180 m=nil [GC worker (idle)]:
runtime.gopark(0x239efffbd4d?, 0x0?, 0x0?, 0x0?, 0x0?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc00005e750 sp=0xc00005e730 pc=0x43b3ce
runtime.gcBgMarkWorker()
	/usr/local/go/src/runtime/mgc.go:1310 +0xe5 fp=0xc00005e7e0 sp=0xc00005e750 pc=0x41d5a5
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc00005e7e8 sp=0xc00005e7e0 pc=0x46d561
created by runtime.gcBgMarkStartWorkers in goroutine 1
	/usr/local/go/src/runtime/mgc.go:1234 +0x1c

goroutine 19 gp=0xc0000b3340 m=nil [GC worker (idle)]:
runtime.gopark(0x239efffbd4d?, 0x0?, 0x0?, 0x0?, 0x0?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc00005ef50 sp=0xc00005ef30 pc=0x43b3ce
runtime.gcBgMarkWorker()
	/usr/local/go/src/runtime/mgc.go:1310 +0xe5 fp=0xc00005efe0 sp=0xc00005ef50 pc=0x41d5a5
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc00005efe8 sp=0xc00005efe0 pc=0x46d561
created by runtime.gcBgMarkStartWorkers in goroutine 1
	/usr/local/go/src/runtime/mgc.go:1234 +0x1c

goroutine 20 gp=0xc0000b3500 m=nil [select, 2 minutes]:
runtime.gopark(0xc00005f778?, 0x2?, 0x28?, 0xf6?, 0xc00005f75c?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc00005f5f0 sp=0xc00005f5d0 pc=0x43b3ce
runtime.selectgo(0xc00005f778, 0xc00005f758, 0x0?, 0x0, 0x0?, 0x1)
	/usr/local/go/src/runtime/select.go:327 +0x725 fp=0xc00005f710 sp=0xc00005f5f0 pc=0x44c6a5
github.com/go-redis/redis/v8/internal/pool.(*ConnPool).reaper(0xc000472500, 0x0?)
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/go-redis/redis/v8/internal/pool/pool.go:485 +0xc5 fp=0xc00005f7c0 sp=0xc00005f710 pc=0x83a4a5
github.com/go-redis/redis/v8/internal/pool.NewConnPool.gowrap1()
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/go-redis/redis/v8/internal/pool/pool.go:111 +0x25 fp=0xc00005f7e0 sp=0xc00005f7c0 pc=0x838b45
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc00005f7e8 sp=0xc00005f7e0 pc=0x46d561
created by github.com/go-redis/redis/v8/internal/pool.NewConnPool in goroutine 1
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/go-redis/redis/v8/internal/pool/pool.go:111 +0x1ef

goroutine 21 gp=0xc0000b36c0 m=nil [chan receive, 2 minutes]:
runtime.gopark(0x0?, 0x0?, 0xa0?, 0x5d?, 0xc00046e780?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc000018f00 sp=0xc000018ee0 pc=0x43b3ce
runtime.chanrecv(0xc00047a060, 0xc000018fb8, 0x1)
	/usr/local/go/src/runtime/chan.go:583 +0x3bf fp=0xc000018f78 sp=0xc000018f00 pc=0x4072ff
runtime.chanrecv2(0xdf8475800?, 0x0?)
	/usr/local/go/src/runtime/chan.go:447 +0x12 fp=0xc000018fa0 sp=0xc000018f78 pc=0x406f32
wind.com/feit-transport/src/mtproto.StartCheckInactiveClientTask()
	/Volumes/wind_ssd/project/go-project/feit-transport/src/mtproto/api.go:27 +0x59 fp=0xc000018fe0 sp=0xc000018fa0 pc=0x84c959
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000018fe8 sp=0xc000018fe0 pc=0x46d561
created by main.main in goroutine 1
	/Volumes/wind_ssd/project/go-project/feit-transport/src/main.go:16 +0xca

goroutine 5 gp=0xc000007340 m=nil [IO wait]:
runtime.gopark(0xd4?, 0xc000023958?, 0x40?, 0x39?, 0xb?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc000023910 sp=0xc0000238f0 pc=0x43b3ce
runtime.netpollblock(0x4ab4b8?, 0x405526?, 0x0?)
	/usr/local/go/src/runtime/netpoll.go:573 +0xf7 fp=0xc000023948 sp=0xc000023910 pc=0x434297
internal/poll.runtime_pollWait(0x7f589ee43d78, 0x72)
	/usr/local/go/src/runtime/netpoll.go:345 +0x85 fp=0xc000023968 sp=0xc000023948 pc=0x467fe5
internal/poll.(*pollDesc).wait(0xc00042c000?, 0xc000000000?, 0x0)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:84 +0x27 fp=0xc000023990 sp=0xc000023968 pc=0x4c3267
internal/poll.(*pollDesc).waitRead(...)
	/usr/local/go/src/internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0xc00042c000, {0xc000000000, 0x1000, 0x1000})
	/usr/local/go/src/internal/poll/fd_unix.go:164 +0x27a fp=0xc000023a28 sp=0xc000023990 pc=0x4c3f7a
net.(*netFD).Read(0xc00042c000, {0xc000000000?, 0xc000023a98?, 0x4c3725?})
	/usr/local/go/src/net/fd_posix.go:55 +0x25 fp=0xc000023a70 sp=0xc000023a28 pc=0x571045
net.(*conn).Read(0xc000096030, {0xc000000000?, 0x0?, 0xc0004340c8?})
	/usr/local/go/src/net/net.go:179 +0x45 fp=0xc000023ab8 sp=0xc000023a70 pc=0x57ba85
net.(*TCPConn).Read(0xc0004340c0?, {0xc000000000?, 0xc00042c000?, 0xc000023af0?})
	<autogenerated>:1 +0x25 fp=0xc000023ae8 sp=0xc000023ab8 pc=0x586f45
net/http.(*connReader).Read(0xc0004340c0, {0xc000000000, 0x1000, 0x1000})
	/usr/local/go/src/net/http/server.go:789 +0x14b fp=0xc000023b38 sp=0xc000023ae8 pc=0x64bf8b
bufio.(*Reader).fill(0xc000040240)
	/usr/local/go/src/bufio/bufio.go:110 +0x103 fp=0xc000023b70 sp=0xc000023b38 pc=0x5ed4c3
bufio.(*Reader).Peek(0xc000040240, 0x4)
	/usr/local/go/src/bufio/bufio.go:148 +0x53 fp=0xc000023b90 sp=0xc000023b70 pc=0x5ed5f3
net/http.(*conn).serve(0xc00011e1b0, {0xbf0cb8, 0xc00046ea80})
	/usr/local/go/src/net/http/server.go:2074 +0x749 fp=0xc000023fb8 sp=0xc000023b90 pc=0x651c29
net/http.(*Server).Serve.gowrap3()
	/usr/local/go/src/net/http/server.go:3285 +0x28 fp=0xc000023fe0 sp=0xc000023fb8 pc=0x655d08
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000023fe8 sp=0xc000023fe0 pc=0x46d561
created by net/http.(*Server).Serve in goroutine 1
	/usr/local/go/src/net/http/server.go:3285 +0x4b4

goroutine 51 gp=0xc000007500 m=nil [chan receive]:
runtime.gopark(0x44d445?, 0xc000064f00?, 0x80?, 0xd4?, 0xc000007340?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc000064ef0 sp=0xc000064ed0 pc=0x43b3ce
runtime.chanrecv(0xc000092600, 0x0, 0x1)
	/usr/local/go/src/runtime/chan.go:583 +0x3bf fp=0xc000064f68 sp=0xc000064ef0 pc=0x4072ff
runtime.chanrecv1(0x1?, 0x0?)
	/usr/local/go/src/runtime/chan.go:442 +0x12 fp=0xc000064f90 sp=0xc000064f68 pc=0x406f12
github.com/amarnathcjd/gogram.closeOnCancel({0xbf0cf0?, 0xc000090e10?}, {0x7f589ecfbfb8, 0xc00046f650})
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:635 +0x32 fp=0xc000064fb0 sp=0xc000064f90 pc=0x7da512
github.com/amarnathcjd/gogram.(*MTProto).connect.gowrap1()
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:310 +0x2c fp=0xc000064fe0 sp=0xc000064fb0 pc=0x7d828c
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000064fe8 sp=0xc000064fe0 pc=0x46d561
created by github.com/amarnathcjd/gogram.(*MTProto).connect in goroutine 25
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:310 +0x1c5

goroutine 25 gp=0xc0000076c0 m=nil [runnable]:
runtime.gopark(0xc0002dfce8?, 0x2?, 0x30?, 0xca?, 0xc0002dfcd4?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc0002dfb80 sp=0xc0002dfb60 pc=0x43b3ce
runtime.selectgo(0xc0002dfce8, 0xc0002dfcd0, 0x14ea7fbecdf?, 0x0, 0x4c3700?, 0x1)
	/usr/local/go/src/runtime/select.go:327 +0x725 fp=0xc0002dfca0 sp=0xc0002dfb80 pc=0x44c6a5
github.com/amarnathcjd/gogram/internal/transport.(*CancelableReader).Read(0xc00024a380, {0xc00025cb64, 0x4, 0xf8da80?})
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/internal/transport/writer.go:48 +0xb3 fp=0xc0002dfd30 sp=0xc0002dfca0 pc=0x7d44d3
github.com/amarnathcjd/gogram/internal/transport.(*tcpConn).Read(0xc0000acc60?, {0xc00025cb64?, 0x4?, 0x4?})
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/internal/transport/connection.go:76 +0x8a fp=0xc0002dfd70 sp=0xc0002dfd30 pc=0x7d21ea
github.com/amarnathcjd/gogram/internal/mode.(*intermediate).ReadMsg(0xc00003e780)
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/internal/mode/intermediate.go:40 +0x56 fp=0xc0002dfdf0 sp=0xc0002dfd70 pc=0x7d0ab6
github.com/amarnathcjd/gogram/internal/transport.(*transport).ReadMsg(0xc00046f650)
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/internal/transport/transport.go:83 +0x2b fp=0xc0002dfe78 sp=0xc0002dfdf0 pc=0x7d3f8b
github.com/amarnathcjd/gogram.(*MTProto).readMsg(0xc00031e6c0)
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:469 +0x34 fp=0xc0002dfef8 sp=0xc0002dfe78 pc=0x7d9334
github.com/amarnathcjd/gogram.(*MTProto).startReadingResponses.func1()
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:416 +0xc5 fp=0xc0002dffe0 sp=0xc0002dfef8 pc=0x7d8be5
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc0002dffe8 sp=0xc0002dffe0 pc=0x46d561
created by github.com/amarnathcjd/gogram.(*MTProto).startReadingResponses in goroutine 10
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:405 +0x90

goroutine 24 gp=0xc000007a40 m=nil [chan receive, 2 minutes]:
runtime.gopark(0xc000040300?, 0x0?, 0x0?, 0x0?, 0x0?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc0000606f0 sp=0xc0000606d0 pc=0x43b3ce
runtime.chanrecv(0xc0001341e0, 0x0, 0x1)
	/usr/local/go/src/runtime/chan.go:583 +0x3bf fp=0xc000060768 sp=0xc0000606f0 pc=0x4072ff
runtime.chanrecv1(0x0?, 0x0?)
	/usr/local/go/src/runtime/chan.go:442 +0x12 fp=0xc000060790 sp=0xc000060768 pc=0x406f12
github.com/amarnathcjd/gogram.closeOnCancel({0xbf0cf0?, 0xc000432550?}, {0x7f589ecfbfb8, 0xc000434f00})
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:635 +0x32 fp=0xc0000607b0 sp=0xc000060790 pc=0x7da512
github.com/amarnathcjd/gogram.(*MTProto).connect.gowrap1()
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:310 +0x2c fp=0xc0000607e0 sp=0xc0000607b0 pc=0x7d828c
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc0000607e8 sp=0xc0000607e0 pc=0x46d561
created by github.com/amarnathcjd/gogram.(*MTProto).connect in goroutine 10
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:310 +0x1c5

goroutine 10 gp=0xc000007c00 m=nil [chan send, 2 minutes]:
runtime.gopark(0x2?, 0xc0000404e0?, 0x10?, 0x2?, 0xc00014fd18?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc000014cc8 sp=0xc000014ca8 pc=0x43b3ce
runtime.chansend(0xc000134120, 0xc000014e38, 0x1, 0xc00014fd40?)
	/usr/local/go/src/runtime/chan.go:259 +0x38d fp=0xc000014d38 sp=0xc000014cc8 pc=0x40658d
runtime.chansend1(0xc00042e140?, 0xc000432400?)
	/usr/local/go/src/runtime/chan.go:145 +0x17 fp=0xc000014d68 sp=0xc000014d38 pc=0x4061f7
github.com/amarnathcjd/gogram.(*MTProto).processResponse(0xc00031e6c0, {0xbf0490, 0xc000474150})
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:535 +0xa6a fp=0xc000014e78 sp=0xc000014d68 pc=0x7da00a
github.com/amarnathcjd/gogram.(*MTProto).readMsg(0xc00031e6c0)
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:492 +0x19e fp=0xc000014ef8 sp=0xc000014e78 pc=0x7d949e
github.com/amarnathcjd/gogram.(*MTProto).startReadingResponses.func1()
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:416 +0xc5 fp=0xc000014fe0 sp=0xc000014ef8 pc=0x7d8be5
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000014fe8 sp=0xc000014fe0 pc=0x46d561
created by github.com/amarnathcjd/gogram.(*MTProto).startReadingResponses in goroutine 5
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/mtproto.go:405 +0x90

goroutine 50 gp=0xc000007dc0 m=nil [runnable]:
runtime.gopark(0x2?, 0xc0000404e0?, 0x1?, 0x0?, 0xc000060ea8?)
	/usr/local/go/src/runtime/proc.go:402 +0xce fp=0xc000060e60 sp=0xc000060e40 pc=0x43b3ce
runtime.chansend(0xc000092480, 0xc000060fa0, 0x1, 0x1?)
	/usr/local/go/src/runtime/chan.go:259 +0x38d fp=0xc000060ed0 sp=0xc000060e60 pc=0x40658d
runtime.chansend1(0xbed0a0?, 0xc000096500?)
	/usr/local/go/src/runtime/chan.go:145 +0x17 fp=0xc000060f00 sp=0xc000060ed0 pc=0x4061f7
github.com/amarnathcjd/gogram/internal/transport.(*CancelableReader).begin(0xc00024a380)
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/internal/transport/writer.go:37 +0x5a fp=0xc000060fc8 sp=0xc000060f00 pc=0x7d425a
github.com/amarnathcjd/gogram/internal/transport.NewCancelableReader.gowrap1()
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/internal/transport/writer.go:81 +0x25 fp=0xc000060fe0 sp=0xc000060fc8 pc=0x7d47e5
runtime.goexit({})
	/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000060fe8 sp=0xc000060fe0 pc=0x46d561
created by github.com/amarnathcjd/gogram/internal/transport.NewCancelableReader in goroutine 25
	/Volumes/wind_ssd/project/go-project/feit-transport/vendor/github.com/amarnathcjd/gogram/internal/transport/writer.go:81 +0x105

Why is there no response when I execute the Connect method?

	log.Printf("init...\n")
	appID := int32(94575)
	appHash := "a3406de8d171bb422bb6ddf3bbd800e2"
	client, _ := telegram.NewClient(telegram.ClientConfig{
		AppID:         appID,
		AppHash:       appHash,
		LogLevel:      telegram.LogDebug,
		StringSession: "1BvXUXQ3ZHVBcWV2MGF5UXFCMHRYWGRORk44Zlh2Z2FJbGI1dVNzVnlRV1cyYXMxS21wVldDWTh6cFordkRUN2xjdmdiSnRpRlVLVlZVUllpRjcyRUJOS3JTYmVnc2JmR3ZhZW91TjBDYTBBQndrV25ON2ptS3FXRzE4aXBsWVNaMlJ0bUdycEtock5lcHB2RDhoM0Via0Q0cU9DRVhZRmpiUDBHOXpjczE5OHJxZklxOWxlbTRYbThsaUhNWEpJeVhmYi9QOGRKV2oybmxUS21FZFZkMWhVZ3FLKy84Lysvay9kNjlLYTA2YUlncVBWZWg4SU5pRlk1TW5LVC9sU2MrS0Vhd2JRV1YyQlo3bzRaTGx6ME1WNCtmMndmRXdoN1J6aGRxWGNlenVxUlVYbGpIWXBDdXVHclZJdUluNlpTMGVINGcrVnhacTJLdHRacm4ydTFiaTBnPT06OlF0N2R1QXFldjBheVFxQjB0WFhkTkZOOGZYdmdhSWxiNXVTc1Z5UVdXMmFzMUttcFZXQ1k4enBaK3ZEVDdsY3ZnYkp0aUZVS1ZWVVJZaUY3MkVCTktyU2JlZ3NiZkd2YWVvdU4wQ2EwQUJ3a1duTjdqbUtxV0cxOGlwbFlTWjJSdG1HcnBLaHJOZXBwdkQ4aDNFYmtENHFPQ0VYWUZqYlAwRzl6Y3MxOThycWZJcTlsZW00WG04bGlITVhKSXlYZmIvUDhkSldqMm5sVEttRWRWZDFoVWdxSysvOC8rL2svZDY5S2EwNmFJZ3FQVmVoOElOaUZZNU1uS1QvbFNjK0tFYXdiUVdWMkJaN280WkxsejBNVjQrZjJ3ZkV3aDdSemhkcVhjZXp1cVJVWGxqSFlwQ3V1R3JWSXVJbjZaUzBlSDRnK1Z4WnEyS3R0WnJuMnUxYmkwZz09Ojo5MS4xMDguNTYuMTMxOjQ0Mzo6BTo68JeFrw",
	})

	client.Connect()
	log.Printf("init end...\n")
2024/03/13 11:26:48 init...
2024/03/13 11:26:48 gogram - cache - debug - initialized cache (gogram_heVF.db) successfully
2024/03/13 11:26:48 gogram - mtproto - debug - importing Auth from stringSession...
2024/03/13 11:26:48 gogram - mtproto - info - Connecting to [91.108.56.131:443] - <TCPFull> ...
2024/03/13 11:26:48 gogram - mtproto - info - Connection to [91.108.56.131:443] - <TCPFull> established
2024/03/13 11:26:48 gogram - client - debug - sending initial invokeWithLayer request

Nil pointer

`panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x6e0e80]

goroutine 160117 [running]:
github.com/amarnathcjd/gogram.(*MTProto).sendPacket(0xc0000c58c0, {0x995720?, 0xc000865d20?}, {0x0, 0x0, 0x0})
/pkg/mod/github.com/amarnathcjd/[email protected]/network.go:59 +0x3c0
github.com/amarnathcjd/gogram.(*MTProto).InvokeRequestWithoutUpdate(0xc0000c58c0?, {0x995720?, 0xc000865d20?}, {0x0?, 0x0?, 0x2?})
/pkg/mod/github.com/amarnathcjd/[email protected]/mtproto.go:312 +0x28
github.com/amarnathcjd/gogram.(*MTProto).Reconnect(0xc0000c58c0, 0x0)
/pkg/mod/github.com/amarnathcjd/[email protected]/mtproto.go:351 +0x158
github.com/amarnathcjd/gogram.(*MTProto).processResponse(0xc0000c58c0, {0x9a3690, 0xc000140690})
/pkg/mod/github.com/amarnathcjd/[email protected]/mtproto.go:483 +0x3b9
github.com/amarnathcjd/gogram.(*MTProto).readMsg(0xc0000c58c0)
/pkg/mod/github.com/amarnathcjd/[email protected]/mtproto.go:446 +0x1b1
github.com/amarnathcjd/gogram.(*MTProto).startReadingResponses.func1()
/pkg/mod/github.com/amarnathcjd/[email protected]/mtproto.go:378 +0xcb
created by github.com/amarnathcjd/gogram.(*MTProto).startReadingResponses
/pkg/mod/github.com/amarnathcjd/[email protected]/mtproto.go:367 +0xaa
`

errorSendPacket := m.transport.WriteMsg(data, MessageRequireToAck(request), seqNo)

AuthImportBotAuthorization:

2023/03/14 23:16:34 sending AuthImportBotAuthorization: Can't make request. Connection is not established

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.