<commit_before>package telegram

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"os"

	tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
	plugin "github.com/scbizu/Astral/astral-plugin"
	"github.com/scbizu/Astral/getcert"
	"github.com/scbizu/Astral/talker"
	"github.com/scbizu/Astral/talker/dce"
	"github.com/sirupsen/logrus"
)

//ListenWebHook is the tg api webhook mode
func ListenWebHook(debug bool) (err error) {
	bot, err := ConnectTG()
	if err != nil {
		return
	}
	if debug {
		bot.Debug = true
		logrus.Infof("bot auth passed as %s", bot.Self.UserName)
	}
	bot.RemoveWebhook()
	cert := getcert.NewDomainCert(tgAPIDomain)
	domainWithToken := fmt.Sprintf("%s%s", cert.GetDomain(), token)
	if _, err = bot.SetWebhook(tgbotapi.NewWebhook(domainWithToken)); err != nil {
		logrus.Infof("notify webhook failed:%s", err.Error())
		return
	}

	info, err := bot.GetWebhookInfo()
	if err != nil {
		return err
	}

	logrus.Info(info.LastErrorMessage, info.LastErrorDate)

	pattern := fmt.Sprintf("/%s", token)
	updatesMsgChannel := bot.ListenForWebhook(pattern)
	logrus.Infof("msg in channel:%d", len(updatesMsgChannel))

	registDCEServer(bot)

	for update := range updatesMsgChannel {
		logrus.Infof("[raw msg]:%#v\n", update)

		if update.Message == nil {
			continue
		}
		pluginHub := plugin.NewTGPluginHub(update.Message)
		var msg tgbotapi.MessageConfig
		if isMsgBadRequest(pluginHub.RegistTGEnabledPlugins(update.Message)) {
			msg = tgbotapi.NewMessage(update.Message.Chat.ID, "Astral服务酱表示不想理你")
		}

		msg.ReplyToMessageID = update.Message.MessageID
		bot.Send(msg)
	}

	return
}
<commit_msg>telegram:fix send empty msg error<commit_after>package telegram

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"os"

	tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
	plugin "github.com/scbizu/Astral/astral-plugin"
	"github.com/scbizu/Astral/getcert"
	"github.com/scbizu/Astral/talker"
	"github.com/scbizu/Astral/talker/dce"
	"github.com/sirupsen/logrus"
)

//ListenWebHook is the tg api webhook mode
func ListenWebHook(debug bool) (err error) {
	bot, err := ConnectTG()
	if err != nil {
		return
	}
	if debug {
		bot.Debug = true
		logrus.Infof("bot auth passed as %s", bot.Self.UserName)
	}
	bot.RemoveWebhook()
	cert := getcert.NewDomainCert(tgAPIDomain)
	domainWithToken := fmt.Sprintf("%s%s", cert.GetDomain(), token)
	if _, err = bot.SetWebhook(tgbotapi.NewWebhook(domainWithToken)); err != nil {
		logrus.Infof("notify webhook failed:%s", err.Error())
		return
	}

	info, err := bot.GetWebhookInfo()
	if err != nil {
		return err
	}

	logrus.Info(info.LastErrorMessage, info.LastErrorDate)

	pattern := fmt.Sprintf("/%s", token)
	updatesMsgChannel := bot.ListenForWebhook(pattern)
	logrus.Infof("msg in channel:%d", len(updatesMsgChannel))

	registDCEServer(bot)

	for update := range updatesMsgChannel {
		logrus.Infof("[raw msg]:%#v\n", update)

		if update.Message == nil {
			continue
		}
		pluginHub := plugin.NewTGPluginHub(update.Message)
		msg := pluginHub.RegistTGEnabledPlugins(update.Message)
		if isMsgBadRequest(msg) {
			msg = tgbotapi.NewMessage(update.Message.Chat.ID, "Astral服务酱表示不想理你")
		}

		msg.ReplyToMessageID = update.Message.MessageID
		bot.Send(msg)
	}

	return
}

{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.0, 'mean_word_length': 4.529310344827586, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2599449', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1240, 'n_words': 215}