|
|
@ -69,6 +69,28 @@ func (b *Btelegram) JoinChannel(channel config.ChannelInfo) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TGGetParseMode(b *Btelegram, username string, text string) (textout string, parsemode string) {
|
|
|
|
|
|
|
|
textout = username + text
|
|
|
|
|
|
|
|
if b.GetString("MessageFormat") == HTMLFormat {
|
|
|
|
|
|
|
|
b.Log.Debug("Using mode HTML")
|
|
|
|
|
|
|
|
parsemode = tgbotapi.ModeHTML
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if b.GetString("MessageFormat") == "Markdown" {
|
|
|
|
|
|
|
|
b.Log.Debug("Using mode markdown")
|
|
|
|
|
|
|
|
parsemode = tgbotapi.ModeMarkdown
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if b.GetString("MessageFormat") == MarkdownV2 {
|
|
|
|
|
|
|
|
b.Log.Debug("Using mode MarkdownV2")
|
|
|
|
|
|
|
|
parsemode = MarkdownV2
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if strings.ToLower(b.GetString("MessageFormat")) == HTMLNick {
|
|
|
|
|
|
|
|
b.Log.Debug("Using mode HTML - nick only")
|
|
|
|
|
|
|
|
textout = username + html.EscapeString(text)
|
|
|
|
|
|
|
|
parsemode = tgbotapi.ModeHTML
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return textout, parsemode
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (b *Btelegram) Send(msg config.Message) (string, error) {
|
|
|
|
func (b *Btelegram) Send(msg config.Message) (string, error) {
|
|
|
|
b.Log.Debugf("=> Receiving %#v", msg)
|
|
|
|
b.Log.Debugf("=> Receiving %#v", msg)
|
|
|
|
|
|
|
|
|
|
|
@ -131,24 +153,7 @@ func (b *Btelegram) getFileDirectURL(id string) string {
|
|
|
|
|
|
|
|
|
|
|
|
func (b *Btelegram) sendMessage(chatid int64, username, text string) (string, error) {
|
|
|
|
func (b *Btelegram) sendMessage(chatid int64, username, text string) (string, error) {
|
|
|
|
m := tgbotapi.NewMessage(chatid, "")
|
|
|
|
m := tgbotapi.NewMessage(chatid, "")
|
|
|
|
m.Text = username + text
|
|
|
|
m.Text, m.ParseMode = TGGetParseMode(b, username, text)
|
|
|
|
if b.GetString("MessageFormat") == HTMLFormat {
|
|
|
|
|
|
|
|
b.Log.Debug("Using mode HTML")
|
|
|
|
|
|
|
|
m.ParseMode = tgbotapi.ModeHTML
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if b.GetString("MessageFormat") == "Markdown" {
|
|
|
|
|
|
|
|
b.Log.Debug("Using mode markdown")
|
|
|
|
|
|
|
|
m.ParseMode = tgbotapi.ModeMarkdown
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if b.GetString("MessageFormat") == MarkdownV2 {
|
|
|
|
|
|
|
|
b.Log.Debug("Using mode MarkdownV2")
|
|
|
|
|
|
|
|
m.ParseMode = MarkdownV2
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if strings.ToLower(b.GetString("MessageFormat")) == HTMLNick {
|
|
|
|
|
|
|
|
b.Log.Debug("Using mode HTML - nick only")
|
|
|
|
|
|
|
|
m.Text = username + html.EscapeString(text)
|
|
|
|
|
|
|
|
m.ParseMode = tgbotapi.ModeHTML
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m.DisableWebPagePreview = b.GetBool("DisableWebPagePreview")
|
|
|
|
m.DisableWebPagePreview = b.GetBool("DisableWebPagePreview")
|
|
|
|
|
|
|
|
|
|
|
|