all repos — escarbot @ main

Earthbound Café's custom Telegram bot, with lots of cool utilities built-in.

escarbot.go (view raw)

 1package main
 2
 3import (
 4	"log"
 5	"os"
 6
 7	"github.com/BiRabittoh/escarbot/telegram"
 8	"github.com/BiRabittoh/escarbot/webui"
 9	"github.com/joho/godotenv"
10)
11
12func main() {
13	err := godotenv.Load()
14	if err != nil {
15		log.Println("No .env file provided.")
16	}
17
18	botToken := os.Getenv("BOT_TOKEN")
19	if botToken == "" {
20		log.Fatal("Please set up your BOT_TOKEN in .env!")
21	}
22
23	channelId := os.Getenv("CHANNEL_ID")
24	if channelId == "" {
25		log.Fatal("Please set up your CHANNEL_ID in .env!")
26	}
27
28	groupId := os.Getenv("GROUP_ID")
29	if groupId == "" {
30		log.Fatal("Please set up your GROUP_ID in .env!")
31	}
32
33	adminId := os.Getenv("ADMIN_ID")
34	if adminId == "" {
35		log.Fatal("Please set up your ADMIN_ID in .env!")
36	}
37
38	port := os.Getenv("PORT")
39	if port == "" {
40		log.Println("PORT not set in .env! Defaulting to 3000.")
41		port = "3000"
42	}
43
44	bot := telegram.NewBot(botToken, channelId, groupId, adminId)
45	ui := webui.NewWebUI(port, bot)
46	ui.Poll()
47}