Skip to content

Commit

Permalink
WIP telegram share track
Browse files Browse the repository at this point in the history
  • Loading branch information
marcio199226 committed Aug 18, 2021
1 parent cb56f9b commit 6fe8ce3
Show file tree
Hide file tree
Showing 200 changed files with 12,430 additions and 3,891 deletions.
14 changes: 12 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ module ytd
go 1.16

require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/fatih/color v1.12.0 // indirect
github.com/kkdai/youtube/v2 v2.7.2
github.com/leaanthony/slicer v1.6.0 // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/mitchellh/mapstructure v1.4.1
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/wailsapp/wails v1.16.3
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/wailsapp/wails v1.16.6
github.com/xujiajun/nutsdb v0.6.0
gopkg.in/tucnak/telebot.v2 v2.3.5 // indirect
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/tucnak/telebot.v2 v2.3.5
)
80 changes: 37 additions & 43 deletions go.sum

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/mitchellh/mapstructure"
"github.com/wailsapp/wails"
"github.com/xujiajun/nutsdb"
tb "gopkg.in/tucnak/telebot.v2"
)

var wailsRuntime *wails.Runtime
Expand Down Expand Up @@ -82,6 +83,23 @@ func (state *AppState) WailsInit(runtime *wails.Runtime) error {
}
}() */

go func() {
for {
restart := make(chan int)
time.Sleep(3 * time.Second)
go state.telegramShareTracks(restart)

for {
select {
case <-restart:
fmt.Println("Share tracks...")
go state.telegramShareTracks(restart)
}

}
}
}()

go func() {
restart := make(chan int)
time.Sleep(3 * time.Second)
Expand Down Expand Up @@ -159,6 +177,44 @@ func (state *AppState) checkForTracksToDownload() error {
return nil
}

type recipientString string

func (r recipientString) Recipient() string {
return r.Recipient()
}

func (state *AppState) telegramShareTracks(restart chan<- int) error {
if !state.Config.Telegram.Share {
// if option is not enabled restart check after 30s
time.Sleep(30 * time.Second)
restart <- 1
return nil
}

b, err := tb.NewBot(tb.Settings{
Token: "1903196088:AAHhWGvfhQfS_MlhvohFvQYnrg3z7GsBPOM",
Poller: &tb.LongPoller{Timeout: 10 * time.Second},
})

if err != nil {
fmt.Println(err)
return nil
}

audio := &tb.Audio{File: tb.FromDisk("/Users/oskarmarciniak/songs/youtube/2vOU4nVI_DA.mp3"), FileName: "Track name", Title: "Track name title", Duration: 207, Caption: "Caption tracks"}
b.Send(&tb.Chat{ID: 903612486}, audio)

b.Handle("/hello", func(m *tb.Message) {
fmt.Println(m.Chat)
b.Send(m.Sender, "Hello World!")
// cercare il primo msg che come username ha quello impostato nell'app e salvarsi la chat_id
})

b.Start()

return nil
}

func (state *AppState) convertToMp3(restart chan<- int) error {
if !state.Config.ConvertToMp3 {
// if option is not enabled restart check after 30s
Expand Down
2 changes: 2 additions & 0 deletions vendor/github.com/Masterminds/semver/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions vendor/github.com/Masterminds/semver/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions vendor/github.com/Masterminds/semver/LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 36 additions & 7 deletions vendor/github.com/Masterminds/semver/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 20 additions & 23 deletions vendor/github.com/Masterminds/semver/constraints.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/Masterminds/semver/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions vendor/github.com/Masterminds/semver/version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vendor/github.com/Masterminds/semver/version_fuzz.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions vendor/github.com/fatih/color/.travis.yml

This file was deleted.

27 changes: 0 additions & 27 deletions vendor/github.com/fatih/color/Gopkg.lock

This file was deleted.

Loading

0 comments on commit 6fe8ce3

Please sign in to comment.