gpt4 book ai didi

go - 如何在golang中发送电报的userleft消息

转载 作者:数据小太阳 更新时间:2023-10-29 03:15:56 26 4
gpt4 key购买 nike

我正在使用 golang 编程语言编写电报机器人。如何在用户离开或加入时发送消息?我试试这个

if (message.UserJoined == true){
bot.SendMessage(message.Chat, "" ,nil)
}

但是它不起作用,我得到这个错误

./main.go:291: invalid operation: message.UserJoined == true (mismatched types telebot.User and bool)

最佳答案

UserJoined 是定义的用户结构:

//UserJoined 可能是机器人本身。

UserJoined User `json:"new_chat_participant"`

Found Here

它不匹配 bool 值

在没有看到其余代码的情况下,我无法判断您要测试消息的目的。

我相信你需要的是类似的东西

if message.UserJoined.ID > 0 {
//Dosomething
}

关于go - 如何在golang中发送电报的userleft消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35923440/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com