本文整理汇总了Golang中github.com/PeterCxy/gotelegram.TObject.Chat方法的典型用法代码示例。如果您正苦于以下问题:Golang TObject.Chat方法的具体用法?Golang TObject.Chat怎么用?Golang TObject.Chat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/PeterCxy/gotelegram.TObject
的用法示例。
在下文中一共展示了TObject.Chat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Command
func (this *Help) Command(name string, msg telegram.TObject, args []string) {
if name == "help" {
if !msg.Chat().IsGroup() {
str := "Source code available at https://github.com/PeterCxy/gotgbot , written in Golang\n\n"
for _, v := range *this.cmds {
// Skip debug functions
if v.Debug {
continue
}
str += fmt.Sprintf(
"/%s %s\n%s\n\n",
v.Name, v.Args, v.Desc)
}
this.tg.ReplyToMessage(msg.MessageId(), str, msg.ChatId())
} else {
this.tg.ReplyToMessage(msg.MessageId(), "Help only available in private chats.", msg.ChatId())
}
} else if name == "father" {
if !msg.Chat().IsGroup() {
str := ""
for _, v := range *this.cmds {
if v.Debug {
continue
}
str += fmt.Sprintf(
"%s - %s %s\n",
v.Name, v.Args, strings.Split(v.Desc, "\n")[0])
}
this.tg.ReplyToMessage(msg.MessageId(), str, msg.ChatId())
}
}
}
示例2: Command
func (this *Scholar) Command(name string, msg telegram.TObject, args []string) {
if name == "calc" {
res, err := calc.Calculate(strings.Join(args, " "))
if err == nil {
this.tg.ReplyToMessage(msg.MessageId(), fmt.Sprintf("%f", res), msg.ChatId())
} else {
this.tg.ReplyToMessage(msg.MessageId(), err.Error(), msg.ChatId())
}
} else if name == "google" {
query := strings.Join(args, " ")
if query == "" {
this.tg.ReplyToMessage(msg.MessageId(), "Please provide something to search for.", msg.ChatId())
} else {
num := 5
maxNum := 5
irc := false
if (msg.Chat()["title"] != nil) && strings.HasPrefix(msg.Chat()["title"].(string), "#") {
num = 1 // Disable long output in IRC-connected groups
irc = true
}
this.tg.SendChatAction("typing", msg.ChatId())
res, hasNext := Google(query, 0, maxNum, this.ipv6)
if len(res) > num {
res = res[0:num]
}
if irc {
hasNext = false
}
this.tg.SendMessageNoPreview(formatGoogle(res, hasNext), msg.ChatId())
if hasNext {
state := utils.SetGrabber(types.Grabber{
Name: "google",
Uid: msg.FromId(),
Chat: msg.ChatId(),
Processor: this,
})
(*state)["start"] = len(res)
(*state)["query"] = query
}
}
}
}