feat: add get users
This commit is contained in:
		@@ -5,15 +5,12 @@ import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"tg-mc/conf"
 | 
			
		||||
	"tg-mc/services/utils"
 | 
			
		||||
 | 
			
		||||
	tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
 | 
			
		||||
	"github.com/sirupsen/logrus"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	bot *tgbotapi.BotAPI
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func Run(sendFunc func(string) error) {
 | 
			
		||||
	var err error
 | 
			
		||||
 | 
			
		||||
@@ -24,7 +21,7 @@ func Run(sendFunc func(string) error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	client := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyUrl)}}
 | 
			
		||||
	bot, err = tgbotapi.NewBotAPIWithClient(
 | 
			
		||||
	conf.Bot, err = tgbotapi.NewBotAPIWithClient(
 | 
			
		||||
		conf.GetBotSettings().BotToken,
 | 
			
		||||
		tgbotapi.APIEndpoint,
 | 
			
		||||
		client)
 | 
			
		||||
@@ -33,13 +30,13 @@ func Run(sendFunc func(string) error) {
 | 
			
		||||
		log.Panic(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	bot.Debug = true
 | 
			
		||||
	conf.Bot.Debug = true
 | 
			
		||||
 | 
			
		||||
	log.Printf("Authorized on account %s", bot.Self.UserName)
 | 
			
		||||
	log.Printf("Authorized on account %s", conf.Bot.Self.UserName)
 | 
			
		||||
 | 
			
		||||
	u := tgbotapi.NewUpdate(0)
 | 
			
		||||
	u.Timeout = 60
 | 
			
		||||
	updates := bot.GetUpdatesChan(u)
 | 
			
		||||
	updates := conf.Bot.GetUpdatesChan(u)
 | 
			
		||||
 | 
			
		||||
	for update := range updates {
 | 
			
		||||
		if update.Message != nil {
 | 
			
		||||
@@ -48,12 +45,11 @@ func Run(sendFunc func(string) error) {
 | 
			
		||||
				logrus.Infof("id is %d", update.Message.Chat.ID)
 | 
			
		||||
				sendFunc(update.Message.CommandArguments())
 | 
			
		||||
			}
 | 
			
		||||
			if update.Message.Command() == "list" {
 | 
			
		||||
				logrus.Infof("id is %d", update.Message.Chat.ID)
 | 
			
		||||
				m := tgbotapi.NewMessage(update.Message.Chat.ID, utils.GetAlivePlayer())
 | 
			
		||||
				conf.Bot.Send(m)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func SendMsg(msg string) error {
 | 
			
		||||
	msgT := tgbotapi.NewMessage(conf.GetBotSettings().GroupID, msg)
 | 
			
		||||
	_, err := bot.Send(msgT)
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user