all repos — gopipe @ 8223ef17cd00edc14c764e8f9874a05ee2073d0b

Embed YouTube videos on Telegram, Discord and more!

src/app/utils.go (view raw)

 1package app
 2
 3import (
 4	"os"
 5	"strconv"
 6	"strings"
 7)
 8
 9func getEnvDefault(key string, def string) string {
10	res := os.Getenv(key)
11	if res == "" {
12		return def
13	}
14	return res
15}
16
17func parseBool(s string) bool {
18	return strings.ToLower(s) == "true" || s == "1"
19}
20
21func getFormatID(s string) int {
22	formatID, err := strconv.ParseUint(s, 10, 64)
23	if err != nil {
24		formatID = 1
25	}
26	return int(formatID)
27}