func actionDictionary(c *gin.Context, update *telegram.Update) error { vy := vajehyab.VajehYab{Developer: "YourDeveloperName"} vajeh, err := vy.Search(update.Message.Text) if err != nil { panic(err) return err } bot.SendMessage(telegram.NewMessage(update.Message.Chat.ID, vajeh.Data.Text.ToString()+"\nمنبع: "+vajeh.Data.Source.ToString())) return nil }
func actionStart(c *gin.Context, update *telegram.Update) error { bot.SendMessage(telegram.NewMessage(update.Message.Chat.ID, `Hi, I'm a Bot You can start with the following commands /start you just do it /echo echo your text /dict translate english to persian,persian to persian Thanks for messaging me `)) return nil }
func (p *providerTelegram) dispatchLoop() { log.Println("telegram: started message dispatch loop") for msg := range p.out { id, err := strconv.ParseInt(msg.ToUserID, 10, 64) if err != nil { continue } var finalMsg bytes.Buffer template.Must(template.New("tmpl").Parse(msg.Message)).Execute(&finalMsg, struct{ User string }{"@" + msg.ToUserName}) if strings.TrimSpace(finalMsg.String()) == "" { continue } p.tg.Send(tgbotapi.NewMessage(id, finalMsg.String())) time.Sleep(1 * time.Second) } }
func actionEcho(c *gin.Context, update *telegram.Update) error { bot.SendMessage(telegram.NewMessage(update.Message.Chat.ID, update.Message.Text)) return nil }