Skip to content

Commit

Permalink
Merge pull request #2 from helios-ag/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
helios-ag authored May 23, 2022
2 parents dde8d19 + baaadf6 commit c3a0670
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 56 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Go

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18

- name: Prepare
run: go get -t -v ./...

- name: Build
run: go build -v ./...

31 changes: 31 additions & 0 deletions .github/workflows/staticcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "StaticCheck"

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
ci:
name: "Run CI"
strategy:
fail-fast: false
matrix:
os: ["windows-latest", "ubuntu-latest", "macOS-latest"]
go: ["1.18.x"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: WillAbides/[email protected]
with:
go-version: ${{ matrix.go }}
- run: "go test ./..."
- run: "go vet ./..."
- uses: dominikh/[email protected]
with:
version: "2022.1"
install-go: false
cache-key: ${{ matrix.go }}
25 changes: 8 additions & 17 deletions examples/channels-subscribers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ var qs = []*survey.Question{
},
{
Name: "Group",
Prompt: &survey.Input{Message: "Enter group"},
Prompt: &survey.Select{Message: "Choose grouping", Options: []string{"hour", "day", "week", "month"}},
},
{
Name: "StartTime",
Prompt: &survey.Input{Message: "Start Time", Default: ""},
Transform: survey.Title,
Name: "StartTime",
Prompt: &survey.Input{Message: "Start Time", Default: ""},
},
{
Name: "EndTime",
Prompt: &survey.Input{Message: "End Time", Default: ""},
Transform: survey.Title,
Name: "EndTime",
Prompt: &survey.Input{Message: "End Time", Default: ""},
},
}

Expand Down Expand Up @@ -65,12 +63,12 @@ func main() {

var group *string
if answers.Group != "" {
group = String(answers.Group)
group = tgstat.String(answers.Group)
}
req := channels.ChannelSubscribersRequest{
ChannelId: answers.ChannelId,
StartDate: String(startTime),
EndDate: String(endTime),
StartDate: tgstat.String(startTime),
EndDate: tgstat.String(endTime),
Group: group,
}

Expand All @@ -89,10 +87,3 @@ func main() {
}

}

func String(v string) *string {
if v == "" {
return nil
}
return &v
}
8 changes: 4 additions & 4 deletions examples/usage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ func main() {
if stat.SpentChannels != "" {
fmt.Printf("SpentChannels: %s\n", stat.SpentChannels)
}
fmt.Printf("spentRequests: %s\n", stat.SpentRequests)
fmt.Printf("Spent requests: %s\n", stat.SpentRequests)
if stat.SpentWords != "" {
fmt.Printf("spentWords: %s\n", stat.SpentWords)
fmt.Printf("Spent words: %s\n", stat.SpentWords)
}
if stat.SpentObjects != "" {
fmt.Printf("spentObjects: %s\n", stat.SpentObjects)
fmt.Printf("Spent objects: %s\n", stat.SpentObjects)
}
fmt.Printf("Expired at: %s\n", time.Unix(stat.ExpiredAt, 0))
fmt.Printf("Expires at: %s\n", time.Unix(stat.ExpiredAt, 0))
}
}
52 changes: 20 additions & 32 deletions examples/words/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ var qs = []*survey.Question{
Prompt: &survey.Input{Message: "End Time", Default: ""},
},
{
Name: "Hide forwards",
Name: "HideForwards",
Prompt: &survey.Confirm{Message: "Hide Forwards", Default: false},
},
{
Name: "Strong search",
Name: "StrongSearch",
Prompt: &survey.Confirm{Message: "Strong Search", Default: false},
},
{
Name: "Group",
Prompt: &survey.Select{Message: "Choose grouping", Options: []string{"day", "week", "month"}},
},
{
Name: "Extended syntax",
Name: "ExtendedSyntax",
Prompt: &survey.Confirm{Message: "Enable extended syntax", Default: false},
},
{
Name: "Minus words",
Name: "MinusWords",
Prompt: &survey.Input{Message: "Minus Words"},
},
}
Expand Down Expand Up @@ -88,18 +88,18 @@ func main() {

var group *string
if answers.Group != "" {
group = String(answers.Group)
group = tgstat.String(answers.Group)
}
req := words.MentionPeriodRequest{
Q: answers.Q,
PeerType: String(answers.PeerType),
StartDate: String(startTime),
EndDate: String(endTime),
HideForwards: Bool(answers.HideForwards),
StrongSearch: Bool(answers.StrongSearch),
MinusWords: String(answers.MinusWords),
PeerType: tgstat.String(answers.PeerType),
StartDate: tgstat.String(startTime),
EndDate: tgstat.String(endTime),
HideForwards: tgstat.Bool(answers.HideForwards),
StrongSearch: tgstat.Bool(answers.StrongSearch),
MinusWords: tgstat.String(answers.MinusWords),
Group: group,
ExtendedSyntax: Bool(answers.ExtendedSyntax),
ExtendedSyntax: tgstat.Bool(answers.ExtendedSyntax),
}

tgstat.Token = answers.Token
Expand All @@ -119,13 +119,13 @@ func main() {

chanReq := words.MentionsByChannelRequest{
Q: answers.Q,
PeerType: String(answers.PeerType),
StartDate: String(startTime),
EndDate: String(endTime),
HideForwards: Bool(answers.HideForwards),
StrongSearch: Bool(answers.StrongSearch),
MinusWords: String(answers.MinusWords),
ExtendedSyntax: Bool(answers.ExtendedSyntax),
PeerType: tgstat.String(answers.PeerType),
StartDate: tgstat.String(startTime),
EndDate: tgstat.String(endTime),
HideForwards: tgstat.Bool(answers.HideForwards),
StrongSearch: tgstat.Bool(answers.StrongSearch),
MinusWords: tgstat.String(answers.MinusWords),
ExtendedSyntax: tgstat.Bool(answers.ExtendedSyntax),
}

tgstat.Token = answers.Token
Expand All @@ -139,9 +139,8 @@ func main() {

for _, mentions := range mentions.Response.Items {
fmt.Printf("ViewsCount %d\n", mentions.ViewsCount)
fmt.Printf("ChannelID %d\n", mentions.ChannelID)
fmt.Printf("MentionsCount %d\n", mentions.MentionsCount)
fmt.Printf("LastMentionDate %d\n", mentions.LastMentionDate)
fmt.Printf("LastMentionDate %s\n", time.Unix(int64(mentions.LastMentionDate), 0))
}

for _, channelInfo := range mentions.Response.Channels {
Expand All @@ -157,14 +156,3 @@ func main() {
}

}

func String(v string) *string {
if v == "" {
return nil
}
return &v
}

func Bool(b bool) *bool {
return &b
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/AlecAivazis/survey/v2 v2.3.4
github.com/helios-ag/tgstat-go v0.0.0-20220521032945-e3b9ee76e0b5
github.com/helios-ag/tgstat-go v0.0.0-20220522063232-7e04b77ca447
)

require (
Expand Down
12 changes: 10 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 h1:byhDUpfEwjsVQb1vBunvIjh2BHQ9ead57VkAEY4V+Es=
github.com/go-ozzo/ozzo-validation/v4 v4.3.0/go.mod h1:2NKgrcHl3z6cJs+3Oo940FPRiTzuqKbvfrL2RxCj6Ew=
github.com/helios-ag/tgstat-go v0.0.0-20220521032945-e3b9ee76e0b5 h1:LJ8410gSNef/TsN+gk4eEY0/0Fnsn2OegDxlpIqO9PE=
github.com/helios-ag/tgstat-go v0.0.0-20220521032945-e3b9ee76e0b5/go.mod h1:l8KjCQcxlv1Pcb79OuPOAJBmy/tQrQoA9j1qHQ/RJH0=
github.com/helios-ag/tgstat-go v0.0.0-20220514025444-1ff93f879e98 h1:AICOS3vX6gYfn7j45x2HHMG6q6toC6bt+Oi1jcdJhjA=
github.com/helios-ag/tgstat-go v0.0.0-20220514025444-1ff93f879e98/go.mod h1:A3zy1r63M9rGfHgu0bchihyyYdcYlRpc44Mw1prIqfM=
github.com/helios-ag/tgstat-go v0.0.0-20220522063232-7e04b77ca447 h1:fXNZmESUIWYc8c9+48MOTqv/co86PZWUKIsk8wDk/yU=
github.com/helios-ag/tgstat-go v0.0.0-20220522063232-7e04b77ca447/go.mod h1:8tMmg1tM4QLN4IJjm3garwD/3lTW1sbtiB1hSw8VnRs=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
Expand All @@ -35,14 +40,17 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w=
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 h1:EH1Deb8WZJ0xc0WK//leUHXcX9aLE5SymusoTmMZye8=
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
Expand Down

0 comments on commit c3a0670

Please sign in to comment.