telegram.SendMessage   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 9
nop 1
dl 0
loc 13
ccs 0
cts 8
cp 0
crap 6
rs 9.95
c 0
b 0
f 0
1
package telegram
2
3
import (
4
	"os"
5
6
	"github.com/SerhiiCho/shoshka-go/utils"
7
	tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
8
)
9
10
// SendMessage sends message in telegram chat
11
func SendMessage(message string) {
12
	if len(message) == 0 {
13
		return
14
	}
15
16
	bot, err := tgbotapi.NewBotAPI(os.Getenv("BOT_TOKEN"))
17
	utils.HandleError(err, "Bot init error")
18
19
	msg := tgbotapi.NewMessage(getChatID(), message)
20
	msg.DisableWebPagePreview = true
21
22
	_, err = bot.Send(msg)
23
	utils.HandleError(err, "Error sending telegram message")
24
}
25