作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在使用 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"`
它不匹配 bool 值
在没有看到其余代码的情况下,我无法判断您要测试消息的目的。
我相信你需要的是类似的东西
if message.UserJoined.ID > 0 {
//Dosomething
}
关于go - 如何在golang中发送电报的userleft消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35923440/
我是一名优秀的程序员,十分优秀!