bloaterbot
This commit is contained in:
parent
52f69d518a
commit
d53b439455
15 changed files with 452 additions and 0 deletions
24
botIO/authenticate.go
Normal file
24
botIO/authenticate.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package botIO
|
||||
|
||||
import (
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
"log"
|
||||
"watn3y/bloaterbotv3/config"
|
||||
)
|
||||
|
||||
func Authenticate() (tgbotapi.UpdatesChannel, *tgbotapi.BotAPI) {
|
||||
|
||||
b, err := tgbotapi.NewBotAPI(config.BotConfig.APIToken)
|
||||
|
||||
if err != nil {
|
||||
log.Panicf("Failed to connect Bot to Telegram: %v\n", err)
|
||||
}
|
||||
|
||||
b.Debug = config.BotConfig.DebugMode
|
||||
|
||||
u := tgbotapi.NewUpdate(0)
|
||||
u.Timeout = 60
|
||||
log.Printf("Authorized on account %s", b.Self.UserName)
|
||||
|
||||
return b.GetUpdatesChan(u), b
|
||||
}
|
13
botIO/sending.go
Normal file
13
botIO/sending.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package botIO
|
||||
|
||||
import (
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
"log"
|
||||
)
|
||||
|
||||
func SendMessage(message tgbotapi.MessageConfig, bot *tgbotapi.BotAPI) {
|
||||
_, err := bot.Send(message)
|
||||
if err != nil {
|
||||
log.Printf("Failed to send message: %v\n", err)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue