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

Loading…
Cancel
Save