Migrations, new chat_member table
This commit is contained in:
@ -104,6 +104,7 @@ type Captcha struct {
|
||||
MessageID int `db:"message_id"`
|
||||
CorrectAnswer string `db:"correct_answer"`
|
||||
BlockedUntil int64 `db:"blocked_until"`
|
||||
Created int64 `db:"created"`
|
||||
}
|
||||
|
||||
var db *sqlx.DB
|
||||
|
22
src/main.go
22
src/main.go
@ -19,9 +19,11 @@ var BOT_NAME string
|
||||
func main() {
|
||||
log.SetFlags(log.Lshortfile + log.Ltime + log.Ldate)
|
||||
InitResources()
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Println("No .env loaded. Relying on existing variables")
|
||||
|
||||
error := godotenv.Load()
|
||||
|
||||
if error != nil {
|
||||
log.Println("no .env loaded. relying on existing variables")
|
||||
}
|
||||
|
||||
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
|
||||
@ -32,20 +34,20 @@ func main() {
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
db.MustExec(schema)
|
||||
// db.MustExec(schema)
|
||||
|
||||
opts := []bot.Option{
|
||||
bot.WithMiddlewares(logChats, logUsers, checkRegistered),
|
||||
bot.WithDefaultHandler(defaultHandler),
|
||||
}
|
||||
|
||||
b, err := bot.New(os.Getenv("TG_TOKEN"), opts...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
b, error := bot.New(os.Getenv("TG_TOKEN"), opts...)
|
||||
if error != nil {
|
||||
panic(error)
|
||||
}
|
||||
me, err := b.GetMe(ctx)
|
||||
if err != nil {
|
||||
log.Fatalf("Can't get me: %v", err)
|
||||
me, error := b.GetMe(ctx)
|
||||
if error != nil {
|
||||
log.Fatalf("Can't get me: %v", error)
|
||||
}
|
||||
BOT_NAME = me.Username
|
||||
log.Println("Using name", BOT_NAME)
|
||||
|
Reference in New Issue
Block a user