This commit is contained in:
Andrey Belvedersky
2021-06-03 09:30:25 +03:00
parent 18b2d4e554
commit 0aa4922105
9 changed files with 147 additions and 6 deletions

View File

@ -14,12 +14,16 @@ import (
telegram "gopkg.in/tucnak/telebot.v2"
)
// Чатбот
func JiraBot() {
cfg, _ := config.GetConfig()
redis := utils.Redis(cfg.Redis)
ctx := context.Background()
pnsq := utils.GetProducer()
jiraClient, _ := utils.GetClient(&cfg.Jira)
b, err := telegram.NewBot(telegram.Settings{
URL: cfg.Telegram.Url,
@ -41,10 +45,20 @@ func JiraBot() {
b.Handle("/start", scenes.Start(b, cfg))
b.Handle("/exit", scenes.Exit(b, redis, ctx))
b.Handle("/hello", func(m *telegram.Message) {
b.Send(m.Sender, "Hello World!")
messageBody := []byte("hello")
topicName := "error"
// Synchronously publish a single message to the specified topic.
// Messages can also be sent asynchronously and/or in batches.
err = pnsq.Publish(topicName, messageBody)
if err != nil {
log.Fatal(err)
}
})
fmt.Println(templates.Title(b.Me, cfg.BotVersion,jiraClient.GetBaseURL().Host))
fmt.Println(templates.Title(b.Me, cfg.BotVersion, jiraClient.GetBaseURL().Host))
b.Start()
}