package main
import (
- "bufio"
"context"
"log"
"os"
+ "os/signal"
"regexp"
"sort"
"strconv"
"strings"
+ "syscall"
"github.com/bwmarrin/discordgo"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
// Tell the user the bot is online
log.Println("Discord Bot ready.")
- log.Println("Press enter to stop")
- // Wait for a newline symbol, then cancel handling updates
- bufio.NewReader(os.Stdin).ReadBytes('\n')
+ done := make(chan os.Signal, 1)
+ signal.Notify(done, syscall.SIGINT, syscall.SIGTERM)
+ log.Println("Blocking, press ctrl+c to continue...")
+ // Wait for a ctrl+c, then cancel handling updates
+ <-done
cancel()
-
}
func receiveUpdates(ctx context.Context, updates tgbotapi.UpdatesChannel) {