AmarnathCJD / gogram

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

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

Closed jMurad closed 9 months ago

jMurad commented 9 months ago
...
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)

RoseLoverX commented 9 months ago

@jMurad messages.StartBot method is equivalent to http://t.me/usernamebot?start=param or ?startgroup=

https://core.telegram.org/method/messages.startBot

it is used to be used by a userbot account to start a bot what you are doing is trying to send that message on same account, not possible

it should be

bot, _ := client.GetSendablePeer("bot username")
chat, _ := ... chatusername// &telegram.InputPeerSelf{} 

client.MessagesStartBot(bot, chat, int64(rand.Int(..)), "params")
jMurad commented 9 months ago

MessagesStartBot takes as a parameter "bot" type InputUser and GetSendablePeer returns type InputPeer

RoseLoverX commented 9 months ago

@jMurad construct it