2020-05-17 06:25:29 +00:00
|
|
|
package telegram
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
"github.com/yanzay/tbot/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (tb *Bot) myID(m *tbot.Message) {
|
2020-05-18 02:06:52 +00:00
|
|
|
if tb.adminCheck(m.From.ID, false) {
|
2020-05-17 06:25:29 +00:00
|
|
|
tb.Client.SendMessage(m.Chat.ID, strconv.Itoa(m.From.ID))
|
2020-05-18 02:06:52 +00:00
|
|
|
return
|
2020-05-17 06:25:29 +00:00
|
|
|
}
|
2020-05-18 02:06:52 +00:00
|
|
|
|
|
|
|
tb.Client.SendMessage(m.Chat.ID, "You are not an authorized admin.")
|
2020-05-17 06:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (tb *Bot) chatID(m *tbot.Message) {
|
2020-05-18 02:06:52 +00:00
|
|
|
if tb.adminCheck(m.From.ID, false) {
|
|
|
|
tb.Client.SendMessage(m.Chat.ID, m.Chat.ID)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
tb.Client.SendMessage(m.Chat.ID, "You are not an authorized admin.")
|
2020-05-17 06:25:29 +00:00
|
|
|
}
|
|
|
|
|
2020-05-18 02:06:52 +00:00
|
|
|
// adminCheck checks for valid bot admins.
|
|
|
|
func (tb *Bot) adminCheck(id int, callback bool) bool {
|
2020-05-17 06:25:29 +00:00
|
|
|
for _, admin := range tb.Config.Telegram.Admins {
|
2020-05-18 02:06:52 +00:00
|
|
|
if id == admin {
|
2020-05-17 06:25:29 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
2020-05-18 02:06:52 +00:00
|
|
|
|
2020-05-17 06:25:29 +00:00
|
|
|
return false
|
|
|
|
}
|