1

Move from dep to go mod (experiment)

This commit is contained in:
Vladimir Hodakov 2018-12-22 18:03:53 +04:00
parent 3fdcb11dcd
commit 647d9c548b
Signed by: Vladimir Hodakov
GPG Key ID: 673980B6882F82C6
17 changed files with 70 additions and 91 deletions

41
Gopkg.lock generated
View File

@ -1,41 +0,0 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
branch = "master"
digest = "1:cdfaade39c21052a144a32f944ce80030cbdce760d0c63c60ca8b9f59928a6f4"
name = "github.com/Arman92/go-tdlib"
packages = ["."]
pruneopts = "UT"
revision = "9577ff528640031a5c3a5f7386c896255f69c723"
[[projects]]
digest = "1:6112a5eaec2ec65df289ccbb7a730aaf03e3c5cce6c906d367ccf9b7ac567604"
name = "github.com/rs/zerolog"
packages = [
".",
"internal/cbor",
"internal/json",
]
pruneopts = "UT"
revision = "8747b7b3a51b5d08ee7ac50eaf4869edaf9f714a"
version = "v1.11.0"
[[projects]]
digest = "1:4d2e5a73dc1500038e504a8d78b986630e3626dc027bc030ba5c75da257cdb96"
name = "gopkg.in/yaml.v2"
packages = ["."]
pruneopts = "UT"
revision = "51d6538a90f86fe93ac480b35f37b2be17fef232"
version = "v2.2.2"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
input-imports = [
"github.com/Arman92/go-tdlib",
"github.com/rs/zerolog",
"gopkg.in/yaml.v2",
]
solver-name = "gps-cdcl"
solver-version = 1

View File

@ -1,34 +0,0 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true
[[constraint]]
branch = "master"
name = "github.com/Arman92/go-tdlib"
[prune]
go-tests = true
unused-packages = true

View File

@ -8,7 +8,7 @@ import (
"github.com/rs/zerolog" "github.com/rs/zerolog"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"io/ioutil" "io/ioutil"
"lab.wtfteam.pro/fat0troll/fw_zookeeper_helper/internal/config" "lab.wtfteam.pro/fat0troll/fw_zookeeper_helper/local/config"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"

View File

@ -5,7 +5,7 @@ package context
import ( import (
"github.com/rs/zerolog" "github.com/rs/zerolog"
"lab.wtfteam.pro/fat0troll/fw_zookeeper_helper/internal/config" "lab.wtfteam.pro/fat0troll/fw_zookeeper_helper/local/config"
) )
// VERSION is the current bot's version // VERSION is the current bot's version

View File

@ -4,3 +4,5 @@ tdlib:
database_directory: "/tmp/tdlib-db/" database_directory: "/tmp/tdlib-db/"
files_directory: "/tmp/tdlib-files/" files_directory: "/tmp/tdlib-files/"
errors_file: "/tmp/tdlib.txt" errors_file: "/tmp/tdlib.txt"
announce:
channel_id: -1001234567890

7
go.mod Normal file
View File

@ -0,0 +1,7 @@
module lab.wtfteam.pro/fat0troll/fw_zookeeper_helper
require (
github.com/Arman92/go-tdlib v0.0.0-20181103144727-9577ff528640
github.com/rs/zerolog v1.11.0
gopkg.in/yaml.v2 v2.2.2
)

8
go.sum Normal file
View File

@ -0,0 +1,8 @@
github.com/Arman92/go-tdlib v0.0.0-20181103144727-9577ff528640 h1:Esv4AF+AVSwjJJFGVLVBncKgq4z7nikN6TK4X7mj2Vg=
github.com/Arman92/go-tdlib v0.0.0-20181103144727-9577ff528640/go.mod h1:ZzkRfuaFj8etIYMj/ECtXtgfz72RE6U+dos27b3XIwk=
github.com/rs/zerolog v1.11.0 h1:DRuq/S+4k52uJzBQciUcofXx45GrMC6yrEbb/CoK6+M=
github.com/rs/zerolog v1.11.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View File

@ -1,4 +0,0 @@
run:
deadline: 5m
linters:
enable-all: true

9
local/config/announce.go Normal file
View File

@ -0,0 +1,9 @@
// Fantasy World Zookeeper Helper Bot
// Copyright (c) 2018 Vladimir "fat0troll" Hodakov
package config
// Announce is a struch which handles announces configuration
type Announce struct {
ChannelID int64 `yaml:"channel_id"`
}

View File

@ -6,5 +6,6 @@ package config
// Struct is a main configuration structure that holds all other // Struct is a main configuration structure that holds all other
// structs within. // structs within.
type Struct struct { type Struct struct {
TDLib TDLib `yaml:"tdlib"` TDLib TDLib `yaml:"tdlib"`
Announce Announce `yaml:"announce"`
} }

View File

@ -88,6 +88,7 @@ func Connect() {
// Check if message text contains needed battle data // Check if message text contains needed battle data
msgText := updateMsg.Message.Content.(*tdlib.MessageText) msgText := updateMsg.Message.Content.(*tdlib.MessageText)
if strings.HasPrefix(msgText.Text.Text, "Я встретил") { if strings.HasPrefix(msgText.Text.Text, "Я встретил") {
log.Debug().Msgf("%s", msgText.Text.Text)
battleType := "" battleType := ""
battleTag := "" battleTag := ""
if strings.Contains(msgText.Text.Text, "Огров") { if strings.Contains(msgText.Text.Text, "Огров") {
@ -99,16 +100,38 @@ func Connect() {
if strings.Contains(msgText.Text.Text, "Кабанов") { if strings.Contains(msgText.Text.Text, "Кабанов") {
battleType = "Кабаны!" battleType = "Кабаны!"
} }
keyboard := updateMsg.Message.ReplyMarkup.(*tdlib.ReplyMarkupInlineKeyboard) switch updateMsg.Message.ReplyMarkup.(type) {
if len(keyboard.Rows) > 0 { case *tdlib.ReplyMarkupInlineKeyboard:
if len(keyboard.Rows[0]) > 0 { keyboard := updateMsg.Message.ReplyMarkup.(*tdlib.ReplyMarkupInlineKeyboard)
button := keyboard.Rows[0][0] if len(keyboard.Rows) > 0 {
buttonQuery := button.Type.(*tdlib.InlineKeyboardButtonTypeCallback) if len(keyboard.Rows[0]) > 0 {
battleTag = string(buttonQuery.Data) button := keyboard.Rows[0][0]
switch button.Type.(type) {
case *tdlib.InlineKeyboardButtonTypeSwitchInline:
buttonQuery := button.Type.(*tdlib.InlineKeyboardButtonTypeSwitchInline)
battleTag = string(buttonQuery.Query)
default:
log.Error().Msg("Invalid button type")
}
}
} }
default:
log.Error().Msg("Invalid keyboard type")
} }
log.Debug().Msgf("Battle type: %s", battleType) log.Debug().Msgf("Battle type: %s", battleType)
log.Debug().Msgf("Battle type: %s", battleTag) log.Debug().Msgf("Battle tag: %s", battleTag)
reply := tdlib.InputMessageText{
DisableWebPagePreview: true,
Text: &tdlib.FormattedText{
Text: "Вызываю на помощь!",
},
}
_, err := client.SendMessage(updateMsg.Message.ChatID, 0, false, false, nil, &reply)
if err != nil {
log.Error().Err(err)
}
} }
} }

View File

@ -5,7 +5,7 @@ package main
import ( import (
"lab.wtfteam.pro/fat0troll/fw_zookeeper_helper/context" "lab.wtfteam.pro/fat0troll/fw_zookeeper_helper/context"
"lab.wtfteam.pro/fat0troll/fw_zookeeper_helper/internal/telegram" "lab.wtfteam.pro/fat0troll/fw_zookeeper_helper/local/telegram"
"os" "os"
"os/signal" "os/signal"
"runtime" "runtime"

0
vendor/github.com/Arman92/go-tdlib/methods.go generated vendored Executable file → Normal file
View File

0
vendor/github.com/Arman92/go-tdlib/types.go generated vendored Executable file → Normal file
View File

8
vendor/modules.txt vendored Normal file
View File

@ -0,0 +1,8 @@
# github.com/Arman92/go-tdlib v0.0.0-20181103144727-9577ff528640
github.com/Arman92/go-tdlib
# github.com/rs/zerolog v1.11.0
github.com/rs/zerolog
github.com/rs/zerolog/internal/cbor
github.com/rs/zerolog/internal/json
# gopkg.in/yaml.v2 v2.2.2
gopkg.in/yaml.v2