Spaces:
Sleeping
Sleeping
Delete cmd
Browse files- cmd/fsb/main.go +0 -37
- cmd/fsb/run.go +0 -87
- cmd/fsb/session.go +0 -41
cmd/fsb/main.go
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
package main
|
| 2 |
-
|
| 3 |
-
import (
|
| 4 |
-
"EverythingSuckz/fsb/config"
|
| 5 |
-
"fmt"
|
| 6 |
-
"os"
|
| 7 |
-
|
| 8 |
-
"github.com/spf13/cobra"
|
| 9 |
-
)
|
| 10 |
-
|
| 11 |
-
const versionString = "3.2.0"
|
| 12 |
-
|
| 13 |
-
var rootCmd = &cobra.Command{
|
| 14 |
-
Use: "fsb [command]",
|
| 15 |
-
Short: "Telegram File Stream Bot",
|
| 16 |
-
Long: "Telegram Bot to generate direct streamable links for telegram media.",
|
| 17 |
-
Example: "fsb run --port 8080",
|
| 18 |
-
Version: versionString,
|
| 19 |
-
CompletionOptions: cobra.CompletionOptions{DisableDefaultCmd: true},
|
| 20 |
-
Run: func(cmd *cobra.Command, args []string) {
|
| 21 |
-
cmd.Help()
|
| 22 |
-
},
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
-
func init() {
|
| 26 |
-
config.SetFlagsFromConfig(runCmd)
|
| 27 |
-
rootCmd.AddCommand(runCmd)
|
| 28 |
-
rootCmd.AddCommand(sessionCmd)
|
| 29 |
-
rootCmd.SetVersionTemplate(fmt.Sprintf(`Telegram File Stream Bot version %s`, versionString))
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
func main() {
|
| 33 |
-
if err := rootCmd.Execute(); err != nil {
|
| 34 |
-
fmt.Println(err)
|
| 35 |
-
os.Exit(1)
|
| 36 |
-
}
|
| 37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd/fsb/run.go
DELETED
|
@@ -1,87 +0,0 @@
|
|
| 1 |
-
package main
|
| 2 |
-
|
| 3 |
-
import (
|
| 4 |
-
"EverythingSuckz/fsb/config"
|
| 5 |
-
"EverythingSuckz/fsb/internal/bot"
|
| 6 |
-
"EverythingSuckz/fsb/internal/cache"
|
| 7 |
-
"EverythingSuckz/fsb/internal/commands"
|
| 8 |
-
"EverythingSuckz/fsb/internal/routes"
|
| 9 |
-
"EverythingSuckz/fsb/internal/types"
|
| 10 |
-
"EverythingSuckz/fsb/internal/utils"
|
| 11 |
-
"fmt"
|
| 12 |
-
"net/http"
|
| 13 |
-
"time"
|
| 14 |
-
|
| 15 |
-
"github.com/spf13/cobra"
|
| 16 |
-
|
| 17 |
-
"github.com/gin-gonic/gin"
|
| 18 |
-
"go.uber.org/zap"
|
| 19 |
-
)
|
| 20 |
-
|
| 21 |
-
var runCmd = &cobra.Command{
|
| 22 |
-
Use: "run",
|
| 23 |
-
Short: "Run the bot with the given configuration.",
|
| 24 |
-
DisableSuggestions: false,
|
| 25 |
-
Run: runApp,
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
var startTime time.Time = time.Now()
|
| 29 |
-
|
| 30 |
-
func runApp(cmd *cobra.Command, args []string) {
|
| 31 |
-
// initialize logger early so config loading is logged to file
|
| 32 |
-
utils.InitLogger(false)
|
| 33 |
-
config.Load(utils.Logger, cmd)
|
| 34 |
-
// reinitialize with correct dev mode
|
| 35 |
-
utils.InitLogger(config.ValueOf.Dev)
|
| 36 |
-
log := utils.Logger
|
| 37 |
-
mainLogger := log.Named("Main")
|
| 38 |
-
mainLogger.Info("Starting server")
|
| 39 |
-
router := getRouter(log)
|
| 40 |
-
|
| 41 |
-
mainBot, err := bot.StartClient(log)
|
| 42 |
-
if err != nil {
|
| 43 |
-
log.Sugar().Fatalf("Failed to start main bot: %v", err)
|
| 44 |
-
}
|
| 45 |
-
cache.InitCache(log)
|
| 46 |
-
workers, err := bot.StartWorkers(log)
|
| 47 |
-
if err != nil {
|
| 48 |
-
log.Sugar().Fatalf("Failed to start workers: %v", err)
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
commands.SaveTokenFunc = workers.SaveTokenToFirebase
|
| 52 |
-
commands.StartWorkerFunc = workers.Add
|
| 53 |
-
commands.LoadTokensFunc = workers.LoadTokensFromFirebase
|
| 54 |
-
commands.GetWorkerListFunc = workers.GetWorkerListText
|
| 55 |
-
|
| 56 |
-
workers.AddDefaultClient(mainBot, mainBot.Self)
|
| 57 |
-
bot.StartUserBot(log)
|
| 58 |
-
fmt.Println("\n✅ Bot Conectado y Listo.")
|
| 59 |
-
fmt.Printf("🌍 Servidor Fantasma Aiohttp activo en puerto %d\n\n", config.ValueOf.Port)
|
| 60 |
-
mainLogger.Info("Server started", zap.Int("port", config.ValueOf.Port))
|
| 61 |
-
mainLogger.Info("File Stream Bot", zap.String("version", versionString))
|
| 62 |
-
mainLogger.Sugar().Infof("Server is running at %s", config.ValueOf.Host)
|
| 63 |
-
err = router.Run(fmt.Sprintf("0.0.0.0:%d", config.ValueOf.Port))
|
| 64 |
-
if err != nil {
|
| 65 |
-
mainLogger.Sugar().Fatalf("Server failed to start: %v", err)
|
| 66 |
-
}
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
func getRouter(log *zap.Logger) *gin.Engine {
|
| 70 |
-
if config.ValueOf.Dev {
|
| 71 |
-
gin.SetMode(gin.DebugMode)
|
| 72 |
-
} else {
|
| 73 |
-
gin.SetMode(gin.ReleaseMode)
|
| 74 |
-
}
|
| 75 |
-
router := gin.Default()
|
| 76 |
-
router.Use(gin.ErrorLogger())
|
| 77 |
-
router.GET("/", func(ctx *gin.Context) {
|
| 78 |
-
ctx.JSON(http.StatusOK, types.RootResponse{
|
| 79 |
-
Message: "Server is running.",
|
| 80 |
-
Ok: true,
|
| 81 |
-
Uptime: utils.TimeFormat(uint64(time.Since(startTime).Seconds())),
|
| 82 |
-
Version: versionString,
|
| 83 |
-
})
|
| 84 |
-
})
|
| 85 |
-
routes.Load(log, router)
|
| 86 |
-
return router
|
| 87 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd/fsb/session.go
DELETED
|
@@ -1,41 +0,0 @@
|
|
| 1 |
-
package main
|
| 2 |
-
|
| 3 |
-
import (
|
| 4 |
-
"fmt"
|
| 5 |
-
|
| 6 |
-
"EverythingSuckz/fsb/pkg/qrlogin"
|
| 7 |
-
|
| 8 |
-
"github.com/spf13/cobra"
|
| 9 |
-
)
|
| 10 |
-
|
| 11 |
-
var sessionCmd = &cobra.Command{
|
| 12 |
-
Use: "session",
|
| 13 |
-
Short: "Generate a string session.",
|
| 14 |
-
DisableSuggestions: false,
|
| 15 |
-
Run: generateSession,
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
func init() {
|
| 19 |
-
sessionCmd.Flags().StringP("login-type", "T", "qr", "The login type to use. Can be either 'qr' or 'phone'")
|
| 20 |
-
sessionCmd.Flags().Int32P("api-id", "I", 0, "The API ID to use for the session (required).")
|
| 21 |
-
sessionCmd.Flags().StringP("api-hash", "H", "", "The API hash to use for the session (required).")
|
| 22 |
-
sessionCmd.MarkFlagRequired("api-id")
|
| 23 |
-
sessionCmd.MarkFlagRequired("api-hash")
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
func generateSession(cmd *cobra.Command, args []string) {
|
| 27 |
-
loginType, _ := cmd.Flags().GetString("login-type")
|
| 28 |
-
apiId, _ := cmd.Flags().GetInt32("api-id")
|
| 29 |
-
apiHash, _ := cmd.Flags().GetString("api-hash")
|
| 30 |
-
if loginType == "qr" {
|
| 31 |
-
qrlogin.GenerateQRSession(int(apiId), apiHash)
|
| 32 |
-
} else if loginType == "phone" {
|
| 33 |
-
generatePhoneSession()
|
| 34 |
-
} else {
|
| 35 |
-
fmt.Println("Invalid login type. Please use either 'qr' or 'phone'")
|
| 36 |
-
}
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
func generatePhoneSession() {
|
| 40 |
-
fmt.Println("Phone session is not implemented yet.")
|
| 41 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|