mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-20 22:16:09 +05:00
add sets for host ts
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
HostTG string
|
HostTG string
|
||||||
|
HostWeb string
|
||||||
WhiteIds []int64
|
WhiteIds []int64
|
||||||
BlackIds []int64
|
BlackIds []int64
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,13 @@ import (
|
|||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
tele "gopkg.in/telebot.v4"
|
tele "gopkg.in/telebot.v4"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"server/log"
|
||||||
"server/settings"
|
"server/settings"
|
||||||
|
"server/tgbot/config"
|
||||||
"server/torr"
|
"server/torr"
|
||||||
"server/web"
|
"server/web"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,15 +29,24 @@ func files(c tele.Context) error {
|
|||||||
t = torr.GetTorrent(args[1])
|
t = torr.GetTorrent(args[1])
|
||||||
}
|
}
|
||||||
c.Bot().Delete(msg)
|
c.Bot().Delete(msg)
|
||||||
host := settings.PubIPv4
|
host := config.Cfg.HostWeb
|
||||||
if host == "" {
|
if host == "" {
|
||||||
ips := web.GetLocalIps()
|
host = settings.PubIPv4
|
||||||
if len(ips) == 0 {
|
if host == "" {
|
||||||
host = "127.0.0.1"
|
ips := web.GetLocalIps()
|
||||||
} else {
|
if len(ips) == 0 {
|
||||||
host = ips[0]
|
host = "127.0.0.1"
|
||||||
|
} else {
|
||||||
|
host = ips[0]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !strings.Contains(host, ":") {
|
||||||
|
host += ":" + settings.Port
|
||||||
|
}
|
||||||
|
if !strings.HasPrefix(host, "http") {
|
||||||
|
host = "http://" + host
|
||||||
|
}
|
||||||
|
|
||||||
t = torr.GetTorrent(args[1])
|
t = torr.GetTorrent(args[1])
|
||||||
ti := t.Status()
|
ti := t.Status()
|
||||||
@@ -49,12 +61,16 @@ func files(c tele.Context) error {
|
|||||||
i := len(txt)
|
i := len(txt)
|
||||||
for _, f := range ti.FileStats {
|
for _, f := range ti.FileStats {
|
||||||
btn := filesKbd.Data("#"+strconv.Itoa(f.Id)+": "+humanize.Bytes(uint64(f.Length))+"\n"+filepath.Base(f.Path), "upload", ti.Hash, strconv.Itoa(f.Id))
|
btn := filesKbd.Data("#"+strconv.Itoa(f.Id)+": "+humanize.Bytes(uint64(f.Length))+"\n"+filepath.Base(f.Path), "upload", ti.Hash, strconv.Itoa(f.Id))
|
||||||
link := filesKbd.URL("Ссылка", "http://"+host+":"+settings.Port+"/stream/"+filepath.Base(f.Path)+"?link="+t.Hash().HexString()+"&index="+strconv.Itoa(f.Id)+"&play")
|
link := filesKbd.URL("Ссылка", host+"/stream/"+filepath.Base(f.Path)+"?link="+t.Hash().HexString()+"&index="+strconv.Itoa(f.Id)+"&play")
|
||||||
files = append(files, filesKbd.Row(btn, link))
|
files = append(files, filesKbd.Row(btn, link))
|
||||||
if i+len(txt) > 1024 || len(files) > 99 {
|
if i+len(txt) > 1024 || len(files) > 99 {
|
||||||
filesKbd := &tele.ReplyMarkup{}
|
filesKbd := &tele.ReplyMarkup{}
|
||||||
filesKbd.Inline(files...)
|
filesKbd.Inline(files...)
|
||||||
c.Send(txt, filesKbd)
|
err = c.Send(txt, filesKbd)
|
||||||
|
if err != nil {
|
||||||
|
log.TLogln("Error send message files:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
files = files[:0]
|
files = files[:0]
|
||||||
i = len(txt)
|
i = len(txt)
|
||||||
}
|
}
|
||||||
@@ -63,7 +79,11 @@ func files(c tele.Context) error {
|
|||||||
|
|
||||||
if len(files) > 0 {
|
if len(files) > 0 {
|
||||||
filesKbd.Inline(files...)
|
filesKbd.Inline(files...)
|
||||||
c.Send(txt, filesKbd)
|
err = c.Send(txt, filesKbd)
|
||||||
|
if err != nil {
|
||||||
|
log.TLogln("Error send message files:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(files) > 1 {
|
if len(files) > 1 {
|
||||||
@@ -75,7 +95,11 @@ func files(c tele.Context) error {
|
|||||||
files = files[:0]
|
files = files[:0]
|
||||||
files = append(files, filesKbd.Row(filesKbd.Data("Скачать все файлы", "uploadall", ti.Hash)))
|
files = append(files, filesKbd.Row(filesKbd.Data("Скачать все файлы", "uploadall", ti.Hash)))
|
||||||
filesKbd.Inline(files...)
|
filesKbd.Inline(files...)
|
||||||
c.Send(txt, filesKbd)
|
err = c.Send(txt, filesKbd)
|
||||||
|
if err != nil {
|
||||||
|
log.TLogln("Error send message files:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user