mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
Api for backup Telegram (#468)
This commit is contained in:
parent
2fbfc88bc1
commit
334b28cddc
2 changed files with 18 additions and 2 deletions
|
@ -1,10 +1,15 @@
|
|||
package controller
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
import (
|
||||
"x-ui/web/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type APIController struct {
|
||||
BaseController
|
||||
inboundController *InboundController
|
||||
Tgbot service.Tgbot
|
||||
}
|
||||
|
||||
func NewAPIController(g *gin.RouterGroup) *APIController {
|
||||
|
@ -32,7 +37,7 @@ func (a *APIController) initRouter(g *gin.RouterGroup) {
|
|||
g.POST("/resetAllTraffics", a.resetAllTraffics)
|
||||
g.POST("/resetAllClientTraffics/:id", a.resetAllClientTraffics)
|
||||
g.POST("/delDepletedClients/:id", a.delDepletedClients)
|
||||
|
||||
g.GET("/createbackup", a.createBackup)
|
||||
a.inboundController = NewInboundController(g)
|
||||
}
|
||||
|
||||
|
@ -95,3 +100,7 @@ func (a *APIController) resetAllClientTraffics(c *gin.Context) {
|
|||
func (a *APIController) delDepletedClients(c *gin.Context) {
|
||||
a.inboundController.delDepletedClients(c)
|
||||
}
|
||||
|
||||
func (a *APIController) createBackup(c *gin.Context) {
|
||||
a.Tgbot.SendBackUP(c)
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"x-ui/util/common"
|
||||
"x-ui/xray"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/mymmrac/telego"
|
||||
th "github.com/mymmrac/telego/telegohandler"
|
||||
tu "github.com/mymmrac/telego/telegoutil"
|
||||
|
@ -500,6 +501,12 @@ func (t *Tgbot) SendReport() {
|
|||
}
|
||||
}
|
||||
|
||||
func (t *Tgbot) SendBackUP(c *gin.Context) {
|
||||
for _, adminId := range adminIds {
|
||||
t.sendBackup(int64(adminId))
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Tgbot) getServerUsage() string {
|
||||
var info string
|
||||
//get hostname
|
||||
|
|
Loading…
Reference in a new issue