chore(prj): optimize imports

This commit is contained in:
iyear 2023-08-20 21:00:06 +08:00
parent d0568bd286
commit d3c02afe24
64 changed files with 234 additions and 134 deletions

View File

@ -2,10 +2,12 @@ package archive
import ( import (
"context" "context"
"github.com/fatih/color"
"github.com/iyear/tdl/pkg/consts"
"github.com/mholt/archiver/v4"
"os" "os"
"github.com/fatih/color"
"github.com/mholt/archiver/v4"
"github.com/iyear/tdl/pkg/consts"
) )
func Backup(ctx context.Context, dst string) error { func Backup(ctx context.Context, dst string) error {

View File

@ -2,12 +2,14 @@ package archive
import ( import (
"context" "context"
"github.com/fatih/color"
"github.com/iyear/tdl/pkg/consts"
"github.com/mholt/archiver/v4"
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"github.com/fatih/color"
"github.com/mholt/archiver/v4"
"github.com/iyear/tdl/pkg/consts"
) )
func Recover(ctx context.Context, file string) error { func Recover(ctx context.Context, file string) error {

View File

@ -4,6 +4,9 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"os"
"time"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/go-faster/jx" "github.com/go-faster/jx"
"github.com/gotd/contrib/middleware/ratelimit" "github.com/gotd/contrib/middleware/ratelimit"
@ -11,17 +14,16 @@ import (
"github.com/gotd/td/telegram/query" "github.com/gotd/td/telegram/query"
"github.com/gotd/td/telegram/query/messages" "github.com/gotd/td/telegram/query/messages"
"github.com/gotd/td/tg" "github.com/gotd/td/tg"
"github.com/jedib0t/go-pretty/v6/progress"
"go.uber.org/multierr"
"golang.org/x/time/rate"
"github.com/iyear/tdl/app/internal/tgc" "github.com/iyear/tdl/app/internal/tgc"
"github.com/iyear/tdl/pkg/prog" "github.com/iyear/tdl/pkg/prog"
"github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/storage"
"github.com/iyear/tdl/pkg/texpr" "github.com/iyear/tdl/pkg/texpr"
"github.com/iyear/tdl/pkg/tmedia" "github.com/iyear/tdl/pkg/tmedia"
"github.com/iyear/tdl/pkg/utils" "github.com/iyear/tdl/pkg/utils"
"github.com/jedib0t/go-pretty/v6/progress"
"go.uber.org/multierr"
"golang.org/x/time/rate"
"os"
"time"
) )
const ( const (

View File

@ -4,22 +4,24 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"strconv"
"strings"
"time"
"github.com/gotd/contrib/middleware/ratelimit" "github.com/gotd/contrib/middleware/ratelimit"
"github.com/gotd/td/telegram/message/peer" "github.com/gotd/td/telegram/message/peer"
"github.com/gotd/td/telegram/peers" "github.com/gotd/td/telegram/peers"
"github.com/gotd/td/telegram/query" "github.com/gotd/td/telegram/query"
"github.com/gotd/td/tg" "github.com/gotd/td/tg"
"github.com/mattn/go-runewidth"
"go.uber.org/zap"
"golang.org/x/time/rate"
"github.com/iyear/tdl/app/internal/tgc" "github.com/iyear/tdl/app/internal/tgc"
"github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/storage"
"github.com/iyear/tdl/pkg/texpr" "github.com/iyear/tdl/pkg/texpr"
"github.com/iyear/tdl/pkg/utils" "github.com/iyear/tdl/pkg/utils"
"github.com/mattn/go-runewidth"
"go.uber.org/zap"
"golang.org/x/time/rate"
"strconv"
"strings"
"time"
) )
type Dialog struct { type Dialog struct {

View File

@ -2,6 +2,7 @@ package chat
import ( import (
"github.com/gotd/td/tg" "github.com/gotd/td/tg"
"github.com/iyear/tdl/pkg/tmedia" "github.com/iyear/tdl/pkg/tmedia"
"github.com/iyear/tdl/pkg/utils" "github.com/iyear/tdl/pkg/utils"
) )

View File

@ -1,8 +1,9 @@
package chat package chat
import ( import (
"github.com/iyear/tdl/pkg/texpr"
"testing" "testing"
"github.com/iyear/tdl/pkg/texpr"
) )
func TestMessageExpr(t *testing.T) { func TestMessageExpr(t *testing.T) {

View File

@ -5,9 +5,14 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/gotd/contrib/middleware/floodwait" "github.com/gotd/contrib/middleware/floodwait"
"github.com/spf13/viper"
"go.uber.org/multierr"
"go.uber.org/zap"
"github.com/iyear/tdl/app/internal/dliter" "github.com/iyear/tdl/app/internal/dliter"
"github.com/iyear/tdl/app/internal/tgc" "github.com/iyear/tdl/app/internal/tgc"
"github.com/iyear/tdl/pkg/consts" "github.com/iyear/tdl/pkg/consts"
@ -16,9 +21,6 @@ import (
"github.com/iyear/tdl/pkg/key" "github.com/iyear/tdl/pkg/key"
"github.com/iyear/tdl/pkg/kv" "github.com/iyear/tdl/pkg/kv"
"github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/logger"
"github.com/spf13/viper"
"go.uber.org/multierr"
"go.uber.org/zap"
) )
type Options struct { type Options struct {

View File

@ -3,20 +3,22 @@ package dl
import ( import (
"context" "context"
"errors" "errors"
"io"
"os"
"strconv"
"github.com/bcicen/jstream" "github.com/bcicen/jstream"
"github.com/gotd/td/telegram/peers" "github.com/gotd/td/telegram/peers"
"github.com/gotd/td/tg" "github.com/gotd/td/tg"
"github.com/mitchellh/mapstructure"
"go.uber.org/zap"
"github.com/iyear/tdl/app/internal/dliter" "github.com/iyear/tdl/app/internal/dliter"
"github.com/iyear/tdl/pkg/dcpool" "github.com/iyear/tdl/pkg/dcpool"
"github.com/iyear/tdl/pkg/kv" "github.com/iyear/tdl/pkg/kv"
"github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/storage"
"github.com/iyear/tdl/pkg/utils" "github.com/iyear/tdl/pkg/utils"
"github.com/mitchellh/mapstructure"
"go.uber.org/zap"
"io"
"os"
"strconv"
) )
const ( const (

View File

@ -2,14 +2,16 @@ package dl
import ( import (
"context" "context"
"github.com/gotd/td/telegram/peers" "github.com/gotd/td/telegram/peers"
"go.uber.org/zap"
"github.com/iyear/tdl/app/internal/dliter" "github.com/iyear/tdl/app/internal/dliter"
"github.com/iyear/tdl/pkg/dcpool" "github.com/iyear/tdl/pkg/dcpool"
"github.com/iyear/tdl/pkg/kv" "github.com/iyear/tdl/pkg/kv"
"github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/storage"
"github.com/iyear/tdl/pkg/utils" "github.com/iyear/tdl/pkg/utils"
"go.uber.org/zap"
) )
func parseURLs(ctx context.Context, pool dcpool.Pool, kvd kv.KV, urls []string) ([]*dliter.Dialog, error) { func parseURLs(ctx context.Context, pool dcpool.Pool, kvd kv.KV, urls []string) ([]*dliter.Dialog, error) {

View File

@ -5,17 +5,19 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"path/filepath"
"text/template"
"time"
"github.com/gotd/td/telegram/peers" "github.com/gotd/td/telegram/peers"
"github.com/gotd/td/telegram/query" "github.com/gotd/td/telegram/query"
"github.com/gotd/td/tg" "github.com/gotd/td/tg"
"github.com/iyear/tdl/pkg/downloader" "github.com/iyear/tdl/pkg/downloader"
"github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/storage"
"github.com/iyear/tdl/pkg/tmedia" "github.com/iyear/tdl/pkg/tmedia"
"github.com/iyear/tdl/pkg/tplfunc" "github.com/iyear/tdl/pkg/tplfunc"
"github.com/iyear/tdl/pkg/utils" "github.com/iyear/tdl/pkg/utils"
"path/filepath"
"text/template"
"time"
) )
func New(ctx context.Context, opts *Options) (*Iter, error) { func New(ctx context.Context, opts *Options) (*Iter, error) {

View File

@ -1,12 +1,14 @@
package dliter package dliter
import ( import (
"github.com/gotd/td/telegram/peers"
"github.com/gotd/td/tg"
"github.com/iyear/tdl/pkg/dcpool"
"github.com/iyear/tdl/pkg/kv"
"sync" "sync"
"text/template" "text/template"
"github.com/gotd/td/telegram/peers"
"github.com/gotd/td/tg"
"github.com/iyear/tdl/pkg/dcpool"
"github.com/iyear/tdl/pkg/kv"
) )
type Options struct { type Options struct {

View File

@ -5,8 +5,9 @@ import (
"crypto/sha256" "crypto/sha256"
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"github.com/iyear/tdl/pkg/utils"
"sort" "sort"
"github.com/iyear/tdl/pkg/utils"
) )
func sortDialogs(dialogs []*Dialog, desc bool) { func sortDialogs(dialogs []*Dialog, desc bool) {

View File

@ -3,9 +3,11 @@ package tgc
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/gotd/td/telegram" "github.com/gotd/td/telegram"
"github.com/iyear/tdl/pkg/logger"
"go.uber.org/zap" "go.uber.org/zap"
"github.com/iyear/tdl/pkg/logger"
) )
func RunWithAuth(ctx context.Context, client *telegram.Client, f func(ctx context.Context) error) error { func RunWithAuth(ctx context.Context, client *telegram.Client, f func(ctx context.Context) error) error {

View File

@ -3,11 +3,18 @@ package tgc
import ( import (
"context" "context"
"fmt" "fmt"
"os"
"path/filepath"
"time"
"github.com/cenkalti/backoff/v4" "github.com/cenkalti/backoff/v4"
"github.com/gotd/contrib/middleware/floodwait" "github.com/gotd/contrib/middleware/floodwait"
tdclock "github.com/gotd/td/clock" tdclock "github.com/gotd/td/clock"
"github.com/gotd/td/telegram" "github.com/gotd/td/telegram"
"github.com/gotd/td/telegram/dcs" "github.com/gotd/td/telegram/dcs"
"github.com/spf13/viper"
"go.uber.org/zap"
"github.com/iyear/tdl/pkg/clock" "github.com/iyear/tdl/pkg/clock"
"github.com/iyear/tdl/pkg/consts" "github.com/iyear/tdl/pkg/consts"
"github.com/iyear/tdl/pkg/key" "github.com/iyear/tdl/pkg/key"
@ -15,11 +22,6 @@ import (
"github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/storage"
"github.com/iyear/tdl/pkg/utils" "github.com/iyear/tdl/pkg/utils"
"github.com/spf13/viper"
"go.uber.org/zap"
"os"
"path/filepath"
"time"
) )
func New(ctx context.Context, login bool, middlewares ...telegram.Middleware) (*telegram.Client, kv.KV, error) { func New(ctx context.Context, login bool, middlewares ...telegram.Middleware) (*telegram.Client, kv.KV, error) {

View File

@ -3,11 +3,12 @@ package login
import ( import (
"context" "context"
"errors" "errors"
"strings"
"github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/gotd/td/telegram/auth" "github.com/gotd/td/telegram/auth"
"github.com/gotd/td/tg" "github.com/gotd/td/tg"
"strings"
) )
// noSignUp can be embedded to prevent signing up. // noSignUp can be embedded to prevent signing up.

View File

@ -3,15 +3,17 @@ package login
import ( import (
"context" "context"
"crypto/rand" "crypto/rand"
"time"
"github.com/cenkalti/backoff/v4" "github.com/cenkalti/backoff/v4"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/gotd/td/telegram" "github.com/gotd/td/telegram"
"github.com/gotd/td/telegram/auth" "github.com/gotd/td/telegram/auth"
"github.com/spf13/viper"
"github.com/iyear/tdl/app/internal/tgc" "github.com/iyear/tdl/app/internal/tgc"
"github.com/iyear/tdl/pkg/consts" "github.com/iyear/tdl/pkg/consts"
"github.com/iyear/tdl/pkg/key" "github.com/iyear/tdl/pkg/key"
"github.com/spf13/viper"
"time"
) )
func Code(ctx context.Context) error { func Code(ctx context.Context) error {

View File

@ -3,10 +3,16 @@ package login
import ( import (
"context" "context"
"fmt" "fmt"
"os"
"path/filepath"
"strconv"
"github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/gotd/td/session" "github.com/gotd/td/session"
tdtdesktop "github.com/gotd/td/session/tdesktop" tdtdesktop "github.com/gotd/td/session/tdesktop"
"github.com/spf13/viper"
"github.com/iyear/tdl/pkg/consts" "github.com/iyear/tdl/pkg/consts"
"github.com/iyear/tdl/pkg/key" "github.com/iyear/tdl/pkg/key"
"github.com/iyear/tdl/pkg/kv" "github.com/iyear/tdl/pkg/kv"
@ -14,10 +20,6 @@ import (
"github.com/iyear/tdl/pkg/tdesktop" "github.com/iyear/tdl/pkg/tdesktop"
"github.com/iyear/tdl/pkg/tpath" "github.com/iyear/tdl/pkg/tpath"
"github.com/iyear/tdl/pkg/utils" "github.com/iyear/tdl/pkg/utils"
"github.com/spf13/viper"
"os"
"path/filepath"
"strconv"
) )
const tdata = "tdata" const tdata = "tdata"

View File

@ -3,13 +3,15 @@ package up
import ( import (
"context" "context"
"fmt" "fmt"
"os"
"path/filepath"
"github.com/gabriel-vasile/mimetype" "github.com/gabriel-vasile/mimetype"
"go.uber.org/zap"
"github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/uploader" "github.com/iyear/tdl/pkg/uploader"
"github.com/iyear/tdl/pkg/utils" "github.com/iyear/tdl/pkg/utils"
"go.uber.org/zap"
"os"
"path/filepath"
) )
type file struct { type file struct {

View File

@ -2,11 +2,13 @@ package up
import ( import (
"context" "context"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/spf13/viper"
"github.com/iyear/tdl/app/internal/tgc" "github.com/iyear/tdl/app/internal/tgc"
"github.com/iyear/tdl/pkg/consts" "github.com/iyear/tdl/pkg/consts"
"github.com/iyear/tdl/pkg/uploader" "github.com/iyear/tdl/pkg/uploader"
"github.com/spf13/viper"
) )
type Options struct { type Options struct {

View File

@ -1,11 +1,12 @@
package up package up
import ( import (
"github.com/iyear/tdl/pkg/consts"
"github.com/iyear/tdl/pkg/utils"
"io/fs" "io/fs"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/iyear/tdl/pkg/consts"
"github.com/iyear/tdl/pkg/utils"
) )
func walk(paths, excludes []string) ([]*file, error) { func walk(paths, excludes []string) ([]*file, error) {

View File

@ -2,9 +2,11 @@ package cmd
import ( import (
"fmt" "fmt"
"github.com/iyear/tdl/app/archive"
"github.com/spf13/cobra"
"time" "time"
"github.com/spf13/cobra"
"github.com/iyear/tdl/app/archive"
) )
func NewBackup() *cobra.Command { func NewBackup() *cobra.Command {

View File

@ -2,11 +2,13 @@ package cmd
import ( import (
"fmt" "fmt"
"math"
"github.com/spf13/cobra"
"github.com/iyear/tdl/app/chat" "github.com/iyear/tdl/app/chat"
"github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/utils" "github.com/iyear/tdl/pkg/utils"
"github.com/spf13/cobra"
"math"
) )
func NewChat() *cobra.Command { func NewChat() *cobra.Command {

View File

@ -2,12 +2,14 @@ package cmd
import ( import (
"fmt" "fmt"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/iyear/tdl/app/dl" "github.com/iyear/tdl/app/dl"
"github.com/iyear/tdl/pkg/consts" "github.com/iyear/tdl/pkg/consts"
"github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/logger"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"strings"
) )
func NewDownload() *cobra.Command { func NewDownload() *cobra.Command {

View File

@ -2,9 +2,10 @@ package cmd
import ( import (
"github.com/fatih/color" "github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/iyear/tdl/app/login" "github.com/iyear/tdl/app/login"
"github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/logger"
"github.com/spf13/cobra"
) )
func NewLogin() *cobra.Command { func NewLogin() *cobra.Command {

View File

@ -1,18 +1,20 @@
package cmd package cmd
import ( import (
"path/filepath"
"strings"
"time"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/iyear/tdl/pkg/consts"
"github.com/iyear/tdl/pkg/kv"
"github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/utils"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/cobra/doc" "github.com/spf13/cobra/doc"
"github.com/spf13/viper" "github.com/spf13/viper"
"go.uber.org/zap" "go.uber.org/zap"
"path/filepath"
"strings" "github.com/iyear/tdl/pkg/consts"
"time" "github.com/iyear/tdl/pkg/kv"
"github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/utils"
) )
func New() *cobra.Command { func New() *cobra.Command {

View File

@ -1,9 +1,10 @@
package cmd package cmd
import ( import (
"github.com/spf13/cobra"
"github.com/iyear/tdl/app/up" "github.com/iyear/tdl/app/up"
"github.com/iyear/tdl/pkg/logger" "github.com/iyear/tdl/pkg/logger"
"github.com/spf13/cobra"
) )
func NewUpload() *cobra.Command { func NewUpload() *cobra.Command {

View File

@ -3,11 +3,13 @@ package cmd
import ( import (
"bytes" "bytes"
_ "embed" _ "embed"
"github.com/fatih/color"
"github.com/iyear/tdl/pkg/consts"
"github.com/spf13/cobra"
"runtime" "runtime"
"text/template" "text/template"
"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/iyear/tdl/pkg/consts"
) )
//go:embed version.tmpl //go:embed version.tmpl

View File

@ -2,10 +2,12 @@ package main
import ( import (
"context" "context"
"github.com/fatih/color"
"github.com/iyear/tdl/cmd"
"os" "os"
"os/signal" "os/signal"
"github.com/fatih/color"
"github.com/iyear/tdl/cmd"
) )
func main() { func main() {

View File

@ -2,9 +2,10 @@ package clock
import ( import (
"fmt" "fmt"
"time"
"github.com/beevik/ntp" "github.com/beevik/ntp"
"github.com/gotd/td/clock" "github.com/gotd/td/clock"
"time"
) )
const defaultHost = "pool.ntp.org" const defaultHost = "pool.ntp.org"

View File

@ -2,13 +2,15 @@ package dcpool
import ( import (
"context" "context"
"sync"
"github.com/gotd/td/telegram" "github.com/gotd/td/telegram"
"github.com/gotd/td/tg" "github.com/gotd/td/tg"
"github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/takeout"
"go.uber.org/multierr" "go.uber.org/multierr"
"go.uber.org/zap" "go.uber.org/zap"
"sync"
"github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/takeout"
) )
type Pool interface { type Pool interface {

View File

@ -4,20 +4,22 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/fatih/color"
"github.com/gabriel-vasile/mimetype"
"github.com/gotd/td/telegram/downloader"
"github.com/iyear/tdl/pkg/dcpool"
"github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/prog"
"github.com/iyear/tdl/pkg/utils"
"github.com/jedib0t/go-pretty/v6/progress"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"time" "time"
"github.com/fatih/color"
"github.com/gabriel-vasile/mimetype"
"github.com/gotd/td/telegram/downloader"
"github.com/jedib0t/go-pretty/v6/progress"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
"github.com/iyear/tdl/pkg/dcpool"
"github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/prog"
"github.com/iyear/tdl/pkg/utils"
) )
const TempExt = ".tmp" const TempExt = ".tmp"

View File

@ -3,6 +3,7 @@ package downloader
import ( import (
"context" "context"
"errors" "errors"
"github.com/gotd/td/tg" "github.com/gotd/td/tg"
) )

View File

@ -2,10 +2,12 @@ package downloader
import ( import (
"context" "context"
"github.com/iyear/tdl/pkg/ps"
"github.com/jedib0t/go-pretty/v6/progress"
"strings" "strings"
"time" "time"
"github.com/jedib0t/go-pretty/v6/progress"
"github.com/iyear/tdl/pkg/ps"
) )
func (d *Downloader) renderPinned(ctx context.Context, pw progress.Writer) { func (d *Downloader) renderPinned(ctx context.Context, pw progress.Writer) {

View File

@ -1,9 +1,10 @@
package downloader package downloader
import ( import (
"github.com/jedib0t/go-pretty/v6/progress"
"os" "os"
"time" "time"
"github.com/jedib0t/go-pretty/v6/progress"
) )
// writeAt wrapper for file to use progress bar // writeAt wrapper for file to use progress bar

View File

@ -2,10 +2,11 @@ package key
import ( import (
"bytes" "bytes"
"github.com/gotd/td/telegram/peers"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"github.com/gotd/td/telegram/peers"
) )
var keyPool = sync.Pool{ var keyPool = sync.Pool{

View File

@ -2,11 +2,13 @@ package kv
import ( import (
"errors" "errors"
"github.com/iyear/tdl/pkg/validator"
"go.etcd.io/bbolt"
"go.uber.org/multierr"
"os" "os"
"time" "time"
"go.etcd.io/bbolt"
"go.uber.org/multierr"
"github.com/iyear/tdl/pkg/validator"
) )
var ( var (

View File

@ -2,6 +2,7 @@ package logger
import ( import (
"context" "context"
"go.uber.org/zap" "go.uber.org/zap"
"go.uber.org/zap/zapcore" "go.uber.org/zap/zapcore"
"gopkg.in/natefinch/lumberjack.v2" "gopkg.in/natefinch/lumberjack.v2"

View File

@ -1,9 +1,10 @@
package prog package prog
import ( import (
"time"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/jedib0t/go-pretty/v6/progress" "github.com/jedib0t/go-pretty/v6/progress"
"time"
) )
func New(formatter progress.UnitsFormatter) progress.Writer { func New(formatter progress.UnitsFormatter) progress.Writer {

View File

@ -3,10 +3,12 @@ package ps
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/iyear/tdl/pkg/utils"
"github.com/shirou/gopsutil/v3/process"
"os" "os"
"runtime" "runtime"
"github.com/shirou/gopsutil/v3/process"
"github.com/iyear/tdl/pkg/utils"
) )
var proc *process.Process var proc *process.Process

View File

@ -3,10 +3,12 @@ package storage
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"strconv"
"github.com/gotd/td/telegram/peers" "github.com/gotd/td/telegram/peers"
"github.com/iyear/tdl/pkg/key" "github.com/iyear/tdl/pkg/key"
"github.com/iyear/tdl/pkg/kv" "github.com/iyear/tdl/pkg/kv"
"strconv"
) )
type Peers struct { type Peers struct {

View File

@ -3,7 +3,9 @@ package storage
import ( import (
"context" "context"
"errors" "errors"
"github.com/gotd/td/telegram" "github.com/gotd/td/telegram"
"github.com/iyear/tdl/pkg/key" "github.com/iyear/tdl/pkg/key"
"github.com/iyear/tdl/pkg/kv" "github.com/iyear/tdl/pkg/kv"
) )

View File

@ -4,7 +4,9 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"errors" "errors"
"github.com/gotd/td/telegram/updates" "github.com/gotd/td/telegram/updates"
"github.com/iyear/tdl/pkg/key" "github.com/iyear/tdl/pkg/key"
"github.com/iyear/tdl/pkg/kv" "github.com/iyear/tdl/pkg/kv"
) )

View File

@ -3,6 +3,7 @@ package takeout
import ( import (
"context" "context"
"errors" "errors"
"github.com/gotd/td/bin" "github.com/gotd/td/bin"
"github.com/gotd/td/telegram" "github.com/gotd/td/telegram"
"github.com/gotd/td/tg" "github.com/gotd/td/tg"

View File

@ -2,7 +2,9 @@ package takeout
import ( import (
"context" "context"
"github.com/gotd/td/tg" "github.com/gotd/td/tg"
"github.com/iyear/tdl/pkg/consts" "github.com/iyear/tdl/pkg/consts"
) )

View File

@ -2,8 +2,9 @@
package tdesktop package tdesktop
import ( import (
_ "unsafe" // for go:linkname
_ "github.com/gotd/td/session/tdesktop" // for FileKey _ "github.com/gotd/td/session/tdesktop" // for FileKey
_ "unsafe" // for go:linkname
) )
//go:linkname FileKey github.com/gotd/td/session/tdesktop.fileKey //go:linkname FileKey github.com/gotd/td/session/tdesktop.fileKey

View File

@ -1,9 +1,10 @@
package texpr package texpr
import ( import (
"sync"
"github.com/antonmedv/expr" "github.com/antonmedv/expr"
"github.com/antonmedv/expr/vm" "github.com/antonmedv/expr/vm"
"sync"
) )
var vmPool = sync.Pool{New: func() any { var vmPool = sync.Pool{New: func() any {

View File

@ -2,9 +2,10 @@ package texpr
import ( import (
"fmt" "fmt"
"github.com/fatih/color"
"reflect" "reflect"
"strings" "strings"
"github.com/fatih/color"
) )
type FieldsGetter struct { type FieldsGetter struct {

View File

@ -1,9 +1,10 @@
package texpr package texpr
import ( import (
"testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"testing"
) )
func TestFieldsGetter(t *testing.T) { func TestFieldsGetter(t *testing.T) {

View File

@ -1,10 +1,12 @@
package tmedia package tmedia
import ( import (
"strconv"
"github.com/gabriel-vasile/mimetype" "github.com/gabriel-vasile/mimetype"
"github.com/gotd/td/tg" "github.com/gotd/td/tg"
"github.com/iyear/tdl/pkg/downloader" "github.com/iyear/tdl/pkg/downloader"
"strconv"
) )
func GetDocumentInfo(doc *tg.MessageMediaDocument) (*downloader.Item, bool) { func GetDocumentInfo(doc *tg.MessageMediaDocument) (*downloader.Item, bool) {

View File

@ -2,6 +2,7 @@ package tmedia
import ( import (
"github.com/gotd/td/tg" "github.com/gotd/td/tg"
"github.com/iyear/tdl/pkg/downloader" "github.com/iyear/tdl/pkg/downloader"
) )

View File

@ -1,9 +1,11 @@
package tmedia package tmedia
import ( import (
"github.com/gotd/td/tg"
"github.com/iyear/tdl/pkg/downloader"
"strconv" "strconv"
"github.com/gotd/td/tg"
"github.com/iyear/tdl/pkg/downloader"
) )
func GetPhotoInfo(photo *tg.MessageMediaPhoto) (*downloader.Item, bool) { func GetPhotoInfo(photo *tg.MessageMediaPhoto) (*downloader.Item, bool) {

View File

@ -3,8 +3,9 @@
package tpath package tpath
import ( import (
"github.com/iyear/tdl/pkg/utils"
"path/filepath" "path/filepath"
"github.com/iyear/tdl/pkg/utils"
) )
// https://github.com/telegramdesktop/tdesktop/blob/dev/Telegram/SourceFiles/platform/linux/specific_linux.cpp#L669-L684 // https://github.com/telegramdesktop/tdesktop/blob/dev/Telegram/SourceFiles/platform/linux/specific_linux.cpp#L669-L684

View File

@ -1,9 +1,10 @@
package tplfunc package tplfunc
import ( import (
"github.com/iancoleman/strcase"
"strings" "strings"
"text/template" "text/template"
"github.com/iancoleman/strcase"
) )
var String = []Func{ var String = []Func{

View File

@ -2,6 +2,7 @@ package uploader
import ( import (
"context" "context"
"github.com/gotd/td/telegram/uploader" "github.com/gotd/td/telegram/uploader"
"github.com/jedib0t/go-pretty/v6/progress" "github.com/jedib0t/go-pretty/v6/progress"
) )

View File

@ -2,10 +2,12 @@ package uploader
import ( import (
"context" "context"
"github.com/iyear/tdl/pkg/ps"
"github.com/jedib0t/go-pretty/v6/progress"
"strings" "strings"
"time" "time"
"github.com/jedib0t/go-pretty/v6/progress"
"github.com/iyear/tdl/pkg/ps"
) )
func runPS(ctx context.Context, pw progress.Writer) { func runPS(ctx context.Context, pw progress.Writer) {

View File

@ -4,20 +4,22 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"io"
"time"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/gotd/td/telegram/message" "github.com/gotd/td/telegram/message"
"github.com/gotd/td/telegram/message/styling" "github.com/gotd/td/telegram/message/styling"
"github.com/gotd/td/telegram/peers" "github.com/gotd/td/telegram/peers"
"github.com/gotd/td/telegram/uploader" "github.com/gotd/td/telegram/uploader"
"github.com/gotd/td/tg" "github.com/gotd/td/tg"
"github.com/jedib0t/go-pretty/v6/progress"
"golang.org/x/sync/errgroup"
"github.com/iyear/tdl/pkg/kv" "github.com/iyear/tdl/pkg/kv"
"github.com/iyear/tdl/pkg/prog" "github.com/iyear/tdl/pkg/prog"
"github.com/iyear/tdl/pkg/storage" "github.com/iyear/tdl/pkg/storage"
"github.com/iyear/tdl/pkg/utils" "github.com/iyear/tdl/pkg/utils"
"github.com/jedib0t/go-pretty/v6/progress"
"golang.org/x/sync/errgroup"
"io"
"time"
) )
var formatter = utils.Byte.FormatBinaryBytes var formatter = utils.Byte.FormatBinaryBytes

View File

@ -2,9 +2,10 @@ package utils
import ( import (
"fmt" "fmt"
"strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"strings"
) )
type cmd struct{} type cmd struct{}

View File

@ -2,9 +2,10 @@ package utils
import ( import (
"fmt" "fmt"
"github.com/yapingcat/gomedia/go-mp4"
"io" "io"
"strings" "strings"
"github.com/yapingcat/gomedia/go-mp4"
) )
type media struct{} type media struct{}

View File

@ -1,8 +1,9 @@
package utils package utils
import ( import (
"golang.org/x/net/proxy"
"net/url" "net/url"
"golang.org/x/net/proxy"
) )
type _proxy struct{} type _proxy struct{}

View File

@ -3,12 +3,13 @@ package utils
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/gotd/td/telegram/peers"
"github.com/gotd/td/telegram/query"
"github.com/gotd/td/tg"
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"github.com/gotd/td/telegram/peers"
"github.com/gotd/td/telegram/query"
"github.com/gotd/td/tg"
) )
type telegram struct{} type telegram struct{}

View File

@ -1,10 +1,11 @@
package test package test
import ( import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"os" "os"
"path/filepath" "path/filepath"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
) )
var _ = Describe("Test tdl archive", func() { var _ = Describe("Test tdl archive", func() {

View File

@ -2,10 +2,12 @@ package test
import ( import (
"encoding/json" "encoding/json"
"github.com/iyear/tdl/app/chat" "strings"
. "github.com/onsi/ginkgo/v2" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"strings"
"github.com/iyear/tdl/app/chat"
) )
var _ = Describe("Test tdl chat ls", FlakeAttempts(3), func() { var _ = Describe("Test tdl chat ls", FlakeAttempts(3), func() {

View File

@ -1,17 +1,19 @@
package test package test
import ( import (
"github.com/fatih/color"
tcmd "github.com/iyear/tdl/cmd"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/spf13/cobra"
"io" "io"
"log" "log"
"os" "os"
"strconv" "strconv"
"testing" "testing"
"time" "time"
"github.com/fatih/color"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/spf13/cobra"
tcmd "github.com/iyear/tdl/cmd"
) )
func TestCommand(t *testing.T) { func TestCommand(t *testing.T) {

View File

@ -1,15 +1,16 @@
package test package test
import ( import (
"github.com/google/uuid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/tidwall/gjson"
"log" "log"
"math/rand" "math/rand"
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
"github.com/google/uuid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/tidwall/gjson"
) )
var _ = Describe("Test tdl upload", FlakeAttempts(3), func() { var _ = Describe("Test tdl upload", FlakeAttempts(3), func() {