Browse Source

Move from dep to go mod (experiment)

tags/1.0.0
Vladimir Hodakov 1 year ago
parent
commit
647d9c548b
Signed by: Vladimir Hodakov <vladimir@hodakov.me> GPG Key ID: 673980B6882F82C6
17 changed files with 70 additions and 91 deletions
  1. +0
    -41
      Gopkg.lock
  2. +0
    -34
      Gopkg.toml
  3. +1
    -1
      context/context.go
  4. +1
    -1
      context/exported.go
  5. +3
    -1
      example/fw_zookeeper_helper.yaml
  6. +7
    -0
      go.mod
  7. +8
    -0
      go.sum
  8. +0
    -4
      golangci.yaml
  9. +9
    -0
      local/config/announce.go
  10. +2
    -1
      local/config/struct.go
  11. +0
    -0
      local/config/tdlib.go
  12. +0
    -0
      local/telegram/exported.go
  13. +30
    -7
      local/telegram/telegram.go
  14. +1
    -1
      main.go
  15. +0
    -0
      vendor/github.com/Arman92/go-tdlib/methods.go
  16. +0
    -0
      vendor/github.com/Arman92/go-tdlib/types.go
  17. +8
    -0
      vendor/modules.txt

+ 0
- 41
Gopkg.lock 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

+ 0
- 34
Gopkg.toml 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

+ 1
- 1
context/context.go View File

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

+ 1
- 1
context/exported.go View File

@@ -5,7 +5,7 @@ package context

import (
"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

+ 3
- 1
example/fw_zookeeper_helper.yaml View File

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

+ 7
- 0
go.mod 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
- 0
go.sum 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=

+ 0
- 4
golangci.yaml View File

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

+ 9
- 0
local/config/announce.go 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"`
}

internal/config/struct.go → local/config/struct.go View File

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

internal/config/tdlib.go → local/config/tdlib.go View File


internal/telegram/exported.go → local/telegram/exported.go View File


internal/telegram/telegram.go → local/telegram/telegram.go View File

@@ -88,6 +88,7 @@ func Connect() {
// Check if message text contains needed battle data
msgText := updateMsg.Message.Content.(*tdlib.MessageText)
if strings.HasPrefix(msgText.Text.Text, "Я встретил") {
log.Debug().Msgf("%s", msgText.Text.Text)
battleType := ""
battleTag := ""
if strings.Contains(msgText.Text.Text, "Огров") {
@@ -99,16 +100,38 @@ func Connect() {
if strings.Contains(msgText.Text.Text, "Кабанов") {
battleType = "Кабаны!"
}
keyboard := updateMsg.Message.ReplyMarkup.(*tdlib.ReplyMarkupInlineKeyboard)
if len(keyboard.Rows) > 0 {
if len(keyboard.Rows[0]) > 0 {
button := keyboard.Rows[0][0]
buttonQuery := button.Type.(*tdlib.InlineKeyboardButtonTypeCallback)
battleTag = string(buttonQuery.Data)
switch updateMsg.Message.ReplyMarkup.(type) {
case *tdlib.ReplyMarkupInlineKeyboard:
keyboard := updateMsg.Message.ReplyMarkup.(*tdlib.ReplyMarkupInlineKeyboard)
if len(keyboard.Rows) > 0 {
if len(keyboard.Rows[0]) > 0 {
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", 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)
}
}
}


+ 1
- 1
main.go View File

@@ -5,7 +5,7 @@ package main

import (
"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/signal"
"runtime"

+ 0
- 0
vendor/github.com/Arman92/go-tdlib/methods.go View File


+ 0
- 0
vendor/github.com/Arman92/go-tdlib/types.go View File


+ 8
- 0
vendor/modules.txt 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

Loading…
Cancel
Save