Browse Source

go fmt

master
Nicolas Massé 6 years ago
parent
commit
f23dd96988
  1. 28
      main.go

28
main.go

@ -1,21 +1,21 @@
package main package main
import ( import (
"log"
"os"
"io"
"net/http"
"fmt" "fmt"
"strings"
"time"
"io/ioutil"
"regexp"
"github.com/go-telegram-bot-api/telegram-bot-api" "github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/spf13/viper" "github.com/spf13/viper"
"unicode"
"golang.org/x/text/transform" "golang.org/x/text/transform"
"golang.org/x/text/unicode/norm" "golang.org/x/text/unicode/norm"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"io"
"io/ioutil"
"log"
"net/http"
"os"
"regexp"
"strings"
"time"
"unicode"
) )
var chatDB map[string]int64 = make(map[string]int64) var chatDB map[string]int64 = make(map[string]int64)
@ -55,7 +55,7 @@ func main() {
} }
target_dir := viper.GetString("TargetDir") target_dir := viper.GetString("TargetDir")
if (target_dir == "") { if target_dir == "" {
panic("No target directory provided!") panic("No target directory provided!")
} }
_, err = os.Stat(target_dir) _, err = os.Stat(target_dir)
@ -73,7 +73,7 @@ func main() {
} }
token := viper.GetString("TelegramToken") token := viper.GetString("TelegramToken")
if (token == "") { if token == "" {
panic("No Telegram Bot Token provided!") panic("No Telegram Bot Token provided!")
} }
@ -99,11 +99,11 @@ func main() {
text := update.Message.Text text := update.Message.Text
username := update.Message.From.UserName username := update.Message.From.UserName
if (username == "") { if username == "" {
replyToCommandWithMessage(bot, update.Message, viper.GetString("MsgNoUsername")) replyToCommandWithMessage(bot, update.Message, viper.GetString("MsgNoUsername"))
continue continue
} }
if (! authorized_users[username]) { if !authorized_users[username] {
log.Printf("[%s] unauthorized user", username) log.Printf("[%s] unauthorized user", username)
replyToCommandWithMessage(bot, update.Message, viper.GetString("MsgForbidden")) replyToCommandWithMessage(bot, update.Message, viper.GetString("MsgForbidden"))
continue continue
@ -284,7 +284,7 @@ func dispatchMessage(bot *tgbotapi.BotAPI, message *tgbotapi.Message) {
func handlePhoto(bot *tgbotapi.BotAPI, message *tgbotapi.Message) error { func handlePhoto(bot *tgbotapi.BotAPI, message *tgbotapi.Message) error {
fileId := "" fileId := ""
maxWidth := 0 maxWidth := 0
for _, photo := range (*message.Photo) { for _, photo := range *message.Photo {
if photo.Width > maxWidth { if photo.Width > maxWidth {
fileId = photo.FileID fileId = photo.FileID
maxWidth = photo.Width maxWidth = photo.Width

Loading…
Cancel
Save