Different activity types

This commit is contained in:
rxdn 2022-06-21 19:26:54 +01:00
parent b0feeb15c9
commit 49ce52283c
17 changed files with 220 additions and 246 deletions

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"github.com/TicketsBot/GoPanel/database" "github.com/TicketsBot/GoPanel/database"
"github.com/TicketsBot/GoPanel/rpc/cache" "github.com/TicketsBot/GoPanel/rpc/cache"
"github.com/TicketsBot/GoPanel/utils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/rxdn/gdl/objects/user" "github.com/rxdn/gdl/objects/user"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
@ -21,10 +22,7 @@ func GetBlacklistHandler(ctx *gin.Context) {
blacklistedUsers, err := database.Client.Blacklist.GetBlacklistedUsers(guildId) blacklistedUsers, err := database.Client.Blacklist.GetBlacklistedUsers(guildId)
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }

View File

@ -26,10 +26,7 @@ func GetGuilds(ctx *gin.Context) {
guilds, err := database.Client.UserGuilds.Get(userId) guilds, err := database.Client.UserGuilds.Get(userId)
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }

View File

@ -1,7 +1,6 @@
package api package api
import ( import (
"fmt"
"github.com/TicketsBot/GoPanel/botcontext" "github.com/TicketsBot/GoPanel/botcontext"
"github.com/TicketsBot/GoPanel/database" "github.com/TicketsBot/GoPanel/database"
"github.com/TicketsBot/GoPanel/rpc" "github.com/TicketsBot/GoPanel/rpc"
@ -42,7 +41,6 @@ func DeletePanel(ctx *gin.Context) {
// Get any multi panels this panel is part of to use later // Get any multi panels this panel is part of to use later
multiPanels, err := database.Client.MultiPanelTargets.GetMultiPanels(panelId) multiPanels, err := database.Client.MultiPanelTargets.GetMultiPanels(panelId)
if err != nil { if err != nil {
fmt.Println(err.Error())
ctx.JSON(500, utils.ErrorJson(err)) ctx.JSON(500, utils.ErrorJson(err))
return return
} }

View File

@ -3,6 +3,7 @@ package api
import ( import (
"context" "context"
dbclient "github.com/TicketsBot/GoPanel/database" dbclient "github.com/TicketsBot/GoPanel/database"
"github.com/TicketsBot/GoPanel/utils"
"github.com/TicketsBot/GoPanel/utils/types" "github.com/TicketsBot/GoPanel/utils/types"
"github.com/TicketsBot/database" "github.com/TicketsBot/database"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -88,10 +89,7 @@ func ListPanels(ctx *gin.Context) {
} }
if err := group.Wait(); err != nil { if err := group.Wait(); err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }

View File

@ -3,6 +3,7 @@ package api
import ( import (
"context" "context"
"github.com/TicketsBot/GoPanel/rpc/cache" "github.com/TicketsBot/GoPanel/rpc/cache"
"github.com/TicketsBot/GoPanel/utils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"strconv" "strconv"
) )
@ -12,19 +13,13 @@ func UserHandler(ctx *gin.Context) {
userId, err := strconv.ParseUint(ctx.Param("user"), 10, 64) userId, err := strconv.ParseUint(ctx.Param("user"), 10, 64)
if err != nil { if err != nil {
ctx.AbortWithStatusJSON(400, gin.H{ ctx.JSON(400, utils.ErrorStr("Invalid user ID"))
"success": false,
"error": "Invalid user ID",
})
return return
} }
var username string var username string
if err := cache.Instance.QueryRow(context.Background(), `SELECT "data"->>'Username' FROM users WHERE users.user_id=$1 AND EXISTS(SELECT FROM members WHERE members.guild_id=$2);`, userId, guildId).Scan(&username); err != nil { if err := cache.Instance.QueryRow(context.Background(), `SELECT "data"->>'Username' FROM users WHERE users.user_id=$1 AND EXISTS(SELECT FROM members WHERE members.guild_id=$2);`, userId, guildId).Scan(&username); err != nil {
ctx.JSON(404, gin.H{ ctx.JSON(404, utils.ErrorStr("Not found"))
"success": false,
"error": "Not found",
})
return return
} }

View File

@ -2,43 +2,43 @@ package api
import ( import (
"github.com/TicketsBot/GoPanel/database" "github.com/TicketsBot/GoPanel/database"
"github.com/TicketsBot/GoPanel/utils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"strconv" "github.com/rxdn/gdl/objects/user"
) )
type whitelabelResponse struct {
Id uint64 `json:"id,string"`
statusUpdateBody
}
func WhitelabelGet(ctx *gin.Context) { func WhitelabelGet(ctx *gin.Context) {
userId := ctx.Keys["userid"].(uint64) userId := ctx.Keys["userid"].(uint64)
// Check if this is a different token // Check if this is a different token
bot, err := database.Client.Whitelabel.GetByUserId(userId) bot, err := database.Client.Whitelabel.GetByUserId(userId)
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }
if bot.BotId == 0 { if bot.BotId == 0 {
ctx.JSON(404, gin.H{ ctx.JSON(404, utils.ErrorStr("No bot found"))
"success": false, return
"error": "No bot found",
})
} else {
// Get status
status, err := database.Client.WhitelabelStatuses.Get(bot.BotId)
if err != nil {
ctx.JSON(500, gin.H{
"success": false,
"error": err.Error(),
})
return
}
ctx.JSON(200, gin.H{
"success": true,
"id": strconv.FormatUint(bot.BotId, 10),
"status": status,
})
} }
// Get status
status, statusType, _, err := database.Client.WhitelabelStatuses.Get(bot.BotId)
if err != nil {
ctx.JSON(500, utils.ErrorJson(err))
return
}
ctx.JSON(200, whitelabelResponse{
Id: bot.BotId,
statusUpdateBody: statusUpdateBody{ // Zero values if no status is fine
Status: status,
StatusType: user.ActivityType(statusType),
},
})
} }

View File

@ -2,6 +2,7 @@ package api
import ( import (
"github.com/TicketsBot/GoPanel/database" "github.com/TicketsBot/GoPanel/database"
"github.com/TicketsBot/GoPanel/utils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@ -10,15 +11,12 @@ func WhitelabelGetErrors(ctx *gin.Context) {
errors, err := database.Client.WhitelabelErrors.GetRecent(userId, 10) errors, err := database.Client.WhitelabelErrors.GetRecent(userId, 10)
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }
ctx.JSON(200, gin.H{ ctx.JSON(200, gin.H{
"success": true, "success": true,
"errors": errors, "errors": errors,
}) })
} }

View File

@ -3,6 +3,7 @@ package api
import ( import (
"github.com/TicketsBot/GoPanel/database" "github.com/TicketsBot/GoPanel/database"
"github.com/TicketsBot/GoPanel/rpc/cache" "github.com/TicketsBot/GoPanel/rpc/cache"
"github.com/TicketsBot/GoPanel/utils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"strconv" "strconv"
) )
@ -12,10 +13,7 @@ func WhitelabelGetGuilds(ctx *gin.Context) {
bot, err := database.Client.Whitelabel.GetByUserId(userId) bot, err := database.Client.Whitelabel.GetByUserId(userId)
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }
@ -24,17 +22,14 @@ func WhitelabelGetGuilds(ctx *gin.Context) {
if bot.BotId == 0 { if bot.BotId == 0 {
ctx.JSON(404, gin.H{ ctx.JSON(404, gin.H{
"success": false, "success": false,
"guilds": guilds, "guilds": guilds,
}) })
return return
} }
ids, err := database.Client.WhitelabelGuilds.GetGuilds(bot.BotId) ids, err := database.Client.WhitelabelGuilds.GetGuilds(bot.BotId)
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }
@ -47,6 +42,6 @@ func WhitelabelGetGuilds(ctx *gin.Context) {
ctx.JSON(200, gin.H{ ctx.JSON(200, gin.H{
"success": true, "success": true,
"guilds": guilds, "guilds": guilds,
}) })
} }

View File

@ -2,6 +2,7 @@ package api
import ( import (
"github.com/TicketsBot/GoPanel/database" "github.com/TicketsBot/GoPanel/database"
"github.com/TicketsBot/GoPanel/utils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@ -15,10 +16,7 @@ func WhitelabelGetPublicKey(ctx *gin.Context) {
// Get bot // Get bot
bot, err := database.Client.Whitelabel.GetByUserId(userId) bot, err := database.Client.Whitelabel.GetByUserId(userId)
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }
@ -33,10 +31,7 @@ func WhitelabelGetPublicKey(ctx *gin.Context) {
key, err := database.Client.WhitelabelKeys.Get(bot.BotId) key, err := database.Client.WhitelabelKeys.Get(bot.BotId)
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }

View File

@ -52,10 +52,7 @@ func WhitelabelPost(ctx *gin.Context) {
// Check if this is a different token // Check if this is a different token
existing, err := dbclient.Client.Whitelabel.GetByUserId(userId) existing, err := dbclient.Client.Whitelabel.GetByUserId(userId)
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }
@ -64,10 +61,7 @@ func WhitelabelPost(ctx *gin.Context) {
BotId: bot.Id, BotId: bot.Id,
Token: token, Token: token,
}); err != nil { }); err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }
@ -78,10 +72,7 @@ func WhitelabelPost(ctx *gin.Context) {
} }
if err := tokenchange.PublishTokenChange(redis.Client.Client, tokenChangeData); err != nil { if err := tokenchange.PublishTokenChange(redis.Client.Client, tokenChangeData); err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }

View File

@ -3,6 +3,7 @@ package api
import ( import (
"encoding/hex" "encoding/hex"
"github.com/TicketsBot/GoPanel/database" "github.com/TicketsBot/GoPanel/database"
"github.com/TicketsBot/GoPanel/utils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@ -16,10 +17,7 @@ func WhitelabelPostPublicKey(ctx *gin.Context) {
// Get bot // Get bot
bot, err := database.Client.Whitelabel.GetByUserId(userId) bot, err := database.Client.Whitelabel.GetByUserId(userId)
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }
@ -52,10 +50,7 @@ func WhitelabelPostPublicKey(ctx *gin.Context) {
} }
if err := database.Client.WhitelabelKeys.Set(bot.BotId, body.PublicKey); err != nil { if err := database.Client.WhitelabelKeys.Set(bot.BotId, body.PublicKey); err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }

View File

@ -3,75 +3,66 @@ package api
import ( import (
"github.com/TicketsBot/GoPanel/database" "github.com/TicketsBot/GoPanel/database"
"github.com/TicketsBot/GoPanel/redis" "github.com/TicketsBot/GoPanel/redis"
"github.com/TicketsBot/GoPanel/utils"
"github.com/TicketsBot/common/statusupdates" "github.com/TicketsBot/common/statusupdates"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/rxdn/gdl/objects/user"
) )
type statusUpdateBody struct {
Status string `json:"status"`
StatusType user.ActivityType `json:"status_type,string"`
}
func WhitelabelStatusPost(ctx *gin.Context) { func WhitelabelStatusPost(ctx *gin.Context) {
userId := ctx.Keys["userid"].(uint64) userId := ctx.Keys["userid"].(uint64)
// Get bot // Get bot
bot, err := database.Client.Whitelabel.GetByUserId(userId) bot, err := database.Client.Whitelabel.GetByUserId(userId)
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, utils.ErrorJson(err))
"success": false,
"error": err.Error(),
})
return return
} }
// Ensure bot exists // Ensure bot exists
if bot.BotId == 0 { if bot.BotId == 0 {
ctx.JSON(404, gin.H{ ctx.JSON(404, utils.ErrorStr("No bot found"))
"success": false,
"error": "No bot found",
})
return return
} }
// Parse status // Parse status
var status string var data statusUpdateBody
{ if err := ctx.BindJSON(&data); err != nil {
var data map[string]string ctx.JSON(400, utils.ErrorStr("Invalid request body"))
if err := ctx.BindJSON(&data); err != nil {
ctx.JSON(400, gin.H{
"success": false,
"error": "No status provided",
})
return
}
var ok bool
status, ok = data["status"]
if !ok {
ctx.JSON(400, gin.H{
"success": false,
"error": "No status provided",
})
return
}
if len(status) == 0 || len(status) > 255 {
ctx.JSON(400, gin.H{
"success": false,
"error": "Status must be between 1-255 characters in length",
})
return
}
}
if err := database.Client.WhitelabelStatuses.Set(bot.BotId, status); err != nil {
ctx.JSON(500, gin.H{
"success": false,
"error": err.Error(),
})
return return
} }
// Validate status length
if len(data.Status) == 0 || len(data.Status) > 255 {
ctx.JSON(400, utils.ErrorStr("Status must be between 1-255 characters in length"))
return
}
// Validate status type
validActivities := []user.ActivityType{
user.ActivityTypePlaying,
user.ActivityTypeListening,
user.ActivityTypeWatching,
}
if !utils.Contains(validActivities, data.StatusType) {
ctx.JSON(400, utils.ErrorStr("Invalid status type"))
return
}
// Update in database
if err := database.Client.WhitelabelStatuses.Set(bot.BotId, data.Status, int16(data.StatusType)); err != nil {
ctx.JSON(500, utils.ErrorJson(err))
return
}
// Send status update to sharder
go statusupdates.Publish(redis.Client.Client, bot.BotId) go statusupdates.Publish(redis.Client.Client, bot.BotId)
ctx.JSON(200, gin.H{ ctx.JSON(200, utils.SuccessResponse)
"success": true,
"bot": bot,
})
} }

View File

@ -53,7 +53,6 @@ var timeout = time.Second * 60
func WebChatWs(ctx *gin.Context) { func WebChatWs(ctx *gin.Context) {
conn, err := upgrader.Upgrade(ctx.Writer, ctx.Request, nil) conn, err := upgrader.Upgrade(ctx.Writer, ctx.Request, nil)
if err != nil { if err != nil {
fmt.Println(err.Error())
return return
} }
@ -95,7 +94,6 @@ func WebChatWs(ctx *gin.Context) {
for { for {
err := conn.WriteMessage(websocket.PingMessage, []byte("keepalive")) err := conn.WriteMessage(websocket.PingMessage, []byte("keepalive"))
if err != nil { if err != nil {
fmt.Println(err.Error())
conn.Close() conn.Close()
conn.CloseHandler()(1000, "") conn.CloseHandler()(1000, "")
return return
@ -156,7 +154,6 @@ func WebChatWs(ctx *gin.Context) {
// Verify the user has permissions to be here // Verify the user has permissions to be here
permLevel, err := utils.GetPermissionLevel(authData.GuildId, userId) permLevel, err := utils.GetPermissionLevel(authData.GuildId, userId)
if err != nil { if err != nil {
fmt.Println(err.Error())
conn.Close() conn.Close()
return return
} }

View File

@ -30,8 +30,6 @@ func Render(payload Payload) ([]byte, error) {
} }
if res.StatusCode != 200 { if res.StatusCode != 200 {
fmt.Println(string(encoded))
sentry.CaptureEvent(&sentry.Event{ sentry.CaptureEvent(&sentry.Event{
Extra: map[string]interface{}{ Extra: map[string]interface{}{
"request_body": string(encoded), "request_body": string(encoded),

View File

@ -1,99 +1,111 @@
<div class="wrapper"> <div class="wrapper">
<div class="content"> <div class="content">
<div class="content-col"> <div class="content-col">
<Card footer="{false}" fill="{false}"> <Card footer="{false}" fill="{false}">
<h4 slot="title">Bot Token</h4> <h4 slot="title">Bot Token</h4>
<div slot="body" class="full-width"> <div slot="body" class="full-width">
<form class="full-width" onsubmit="return false;"> <form class="full-width" onsubmit="return false;">
<label class="form-label">Bot Token</label> <label class="form-label">Bot Token</label>
<input name="token" type="text" bind:value={token} class="form-input full-width" <input name="token" type="text" bind:value={token} class="form-input full-width"
placeholder="xxxxxxxxxxxxxxxxxxxxxxxx.xxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxx"> placeholder="xxxxxxxxxxxxxxxxxxxxxxxx.xxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxx">
<p>Note: You will not be able to view the token after submitting it</p> <p>Note: You will not be able to view the token after submitting it</p>
<div class="buttons"> <div class="buttons">
<div class="col"> <div class="col">
<Button icon="fas fa-paper-plane" on:click={submitToken} fullWidth="{true}">Submit</Button> <Button icon="fas fa-paper-plane" on:click={submitToken} fullWidth="{true}">Submit
</div> </Button>
<div class="col"> </div>
<Button icon="fas fa-plus" on:click={invite} fullWidth="{true}" disabled="{bot.id === undefined}"> <div class="col">
Generate Invite Link <Button icon="fas fa-plus" on:click={invite} fullWidth="{true}"
</Button> disabled="{bot.id === undefined}">
</div> Generate Invite Link
</div> </Button>
</form> </div>
</div>
</form>
</div>
</Card>
</div> </div>
</Card> <div class="content-col">
</div> <Card footer="{false}" fill="{false}">
<div class="content-col"> <h4 slot="title">Slash Commands</h4>
<Card footer="{false}" fill="{false}"> <div slot="body" class="full-width">
<h4 slot="title">Slash Commands</h4> <form class="full-width" onsubmit="return false;">
<div slot="body" class="full-width"> <label class="form-label">Interactions Endpoint URL</label>
<form class="full-width" onsubmit="return false;"> <input name="token" type="text" bind:value={interactionUrl} class="form-input full-width"
<label class="form-label">Interactions Endpoint URL</label> readonly>
<input name="token" type="text" bind:value={interactionUrl} class="form-input full-width" readonly>
<label class="form-label">Public Key</label> <label class="form-label">Public Key</label>
<input name="token" type="text" bind:value={publicKey} class="form-input full-width"> <input name="token" type="text" bind:value={publicKey} class="form-input full-width">
<div class="buttons"> <div class="buttons">
<div class="col"> <div class="col">
<Button icon="fas fa-paper-plane" on:click={updatePublicKey} fullWidth="{true}" <Button icon="fas fa-paper-plane" on:click={updatePublicKey} fullWidth="{true}"
disabled="{bot.id === undefined}">Submit Key disabled="{bot.id === undefined}">Submit Key
</Button> </Button>
</div> </div>
<div class="col"> <div class="col">
<Button icon="fas fa-paper-plane" on:click={createSlashCommands} fullWidth="{true}" <Button icon="fas fa-paper-plane" on:click={createSlashCommands} fullWidth="{true}"
disabled="{!publicKeyOk}">Create Slash Commands disabled="{!publicKeyOk}">Create Slash Commands
</Button> </Button>
</div> </div>
</div> </div>
</form> </form>
</div>
</Card>
</div> </div>
</Card>
</div> </div>
</div> <div class="content">
<div class="content"> <div class="content-col">
<div class="content-col"> <Card footer="{false}" fill="{false}">
<Card footer="{false}" fill="{false}"> <h4 slot="title">Custom Status</h4>
<h4 slot="title">Custom Status</h4> <div slot="body" class="full-width">
<div slot="body" class="full-width"> <form class="form-wrapper full-width" onsubmit="return false;">
<form class="full-width" onsubmit="return false;"> <div class="row">
<label class="form-label">Status</label> <Dropdown col3 label="Status Type" bind:value={bot.status_type}>
<input name="token" type="text" bind:value={bot.status} class="form-input full-width" placeholder="/help"> <option value="0">Playing</option>
<option value="2">Listening</option>
<option value="3">Watching</option>
</Dropdown>
<div class="buttons"> <div class="col-2-3">
<Button icon="fas fa-paper-plane" on:click={updateStatus} fullWidth="{true}" <Input col1 label="Status Text" placeholder="/help" bind:value={bot.status} />
disabled="{bot.id === undefined}">Submit </div>
</Button> </div>
</div>
</form> <div class="buttons">
<Button icon="fas fa-paper-plane" on:click={updateStatus} fullWidth="{true}"
disabled="{bot.id === undefined}">Submit
</Button>
</div>
</form>
</div>
</Card>
</div> </div>
</Card> <div class="content-col">
</div> <Card footer="{false}" fill="{false}">
<div class="content-col"> <h4 slot="title">Error Log</h4>
<Card footer="{false}" fill="{false}"> <div slot="body" class="full-width">
<h4 slot="title">Error Log</h4> <table class="error-log">
<div slot="body" class="full-width"> <thead>
<table class="error-log"> <tr style="border-bottom: 1px solid #dee2e6;">
<thead> <th class="table-col">Error</th>
<tr style="border-bottom: 1px solid #dee2e6;"> <th class="table-col">Time</th>
<th class="table-col">Error</th> </tr>
<th class="table-col">Time</th> </thead>
</tr> <tbody id="error_body">
</thead> {#each errors as error}
<tbody id="error_body"> <tr class="table-row table-border">
{#each errors as error} <td class="table-col">{error.message}</td>
<tr class="table-row table-border"> <td class="table-col">{error.time.toLocaleString()}</td>
<td class="table-col">{error.message}</td> </tr>
<td class="table-col">{error.time.toLocaleString()}</td> {/each}
</tr> </tbody>
{/each} </table>
</tbody> </div>
</table> </Card>
</div> </div>
</Card>
</div> </div>
</div>
</div> </div>
<style> <style>
@ -179,6 +191,22 @@
.table-border { .table-border {
border-top: 1px solid #dee2e6; border-top: 1px solid #dee2e6;
} }
.form-wrapper {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
}
.row {
display: flex;
flex-direction: row;
justify-content: space-between;
width: 100%;
height: 100%;
gap: 10px;
}
</style> </style>
<script> <script>
@ -188,6 +216,8 @@
import Button from '../components/Button.svelte' import Button from '../components/Button.svelte'
import {API_URL} from "../js/constants"; import {API_URL} from "../js/constants";
import {setDefaultHeaders} from '../includes/Auth.svelte' import {setDefaultHeaders} from '../includes/Auth.svelte'
import Input from "../components/form/Input.svelte";
import Dropdown from "../components/form/Dropdown.svelte";
setDefaultHeaders() setDefaultHeaders()
@ -200,7 +230,7 @@
async function invite() { async function invite() {
const res = await axios.get(`${API_URL}/user/whitelabel/`); const res = await axios.get(`${API_URL}/user/whitelabel/`);
if (res.status !== 200 || !res.data.success) { if (res.status !== 200) {
notifyError(res.data.error); notifyError(res.data.error);
return; return;
} }
@ -246,6 +276,7 @@
async function updateStatus() { async function updateStatus() {
const data = { const data = {
status: bot.status, status: bot.status,
status_type: bot.status_type,
}; };
const res = await axios.post(`${API_URL}/user/whitelabel/status`, data); const res = await axios.post(`${API_URL}/user/whitelabel/status`, data);
@ -264,7 +295,7 @@
async function loadBot() { async function loadBot() {
const res = await axios.get(`${API_URL}/user/whitelabel/`); const res = await axios.get(`${API_URL}/user/whitelabel/`);
if (res.status !== 200 || !res.data.success) { if (res.status !== 200) {
if (res.status === 402) { if (res.status === 402) {
window.location.replace("https://ticketsbot.net/premium"); window.location.replace("https://ticketsbot.net/premium");
return false; return false;
@ -273,6 +304,7 @@
if (res.status !== 404) { if (res.status !== 404) {
notifyError(res.data.error); notifyError(res.data.error);
} }
return true; return true;
} }
@ -314,7 +346,7 @@
return; return;
} }
if (res.status !== 200 || !res.data.success) { if (res.status !== 200) {
notifyError(res.data.error); notifyError(res.data.error);
return; return;
} }

8
go.mod
View File

@ -5,10 +5,10 @@ go 1.18
require ( require (
github.com/BurntSushi/toml v0.3.1 github.com/BurntSushi/toml v0.3.1
github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc
github.com/TicketsBot/common v0.0.0-20220609182514-8d43f86e8253 github.com/TicketsBot/common v0.0.0-20220615205931-a6a31e73b52a
github.com/TicketsBot/database v0.0.0-20220618184239-b5ab901854fb github.com/TicketsBot/database v0.0.0-20220621182433-accd1b2b81de
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c
github.com/TicketsBot/worker v0.0.0-20220614162334-f81bf3f39aa5 github.com/TicketsBot/worker v0.0.0-20220621165800-203b0004b733
github.com/apex/log v1.1.2 github.com/apex/log v1.1.2
github.com/getsentry/sentry-go v0.13.0 github.com/getsentry/sentry-go v0.13.0
github.com/gin-contrib/static v0.0.0-20191128031702-f81c604d8ac2 github.com/gin-contrib/static v0.0.0-20191128031702-f81c604d8ac2
@ -22,7 +22,7 @@ require (
github.com/jackc/pgx/v4 v4.7.1 github.com/jackc/pgx/v4 v4.7.1
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/rxdn/gdl v0.0.0-20220614155333-7e6d7486acdd github.com/rxdn/gdl v0.0.0-20220621165443-28e214d254c1
github.com/sirupsen/logrus v1.5.0 github.com/sirupsen/logrus v1.5.0
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
) )

20
go.sum
View File

@ -3,20 +3,16 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/ReneKroon/ttlcache v1.6.0/go.mod h1:DG6nbhXKUQhrExfwwLuZUdH7UnRDDRA1IW+nBuCssvs= github.com/ReneKroon/ttlcache v1.6.0/go.mod h1:DG6nbhXKUQhrExfwwLuZUdH7UnRDDRA1IW+nBuCssvs=
github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc h1:n15W8Eg+ik3/0yqPzZVRP2oZJcIZCIgQ071cZleedKo= github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc h1:n15W8Eg+ik3/0yqPzZVRP2oZJcIZCIgQ071cZleedKo=
github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc/go.mod h1:2KcfHS0JnSsgcxZBs3NyWMXNQzEo67mBSGOyzHPWOCc= github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc/go.mod h1:2KcfHS0JnSsgcxZBs3NyWMXNQzEo67mBSGOyzHPWOCc=
github.com/TicketsBot/common v0.0.0-20220609182514-8d43f86e8253 h1:HbL0OBZHmU0TbB/lAQ9RY0TqxhAKRO8JNh2XUe0NH8c= github.com/TicketsBot/common v0.0.0-20220615205931-a6a31e73b52a h1:SwA18cDURmnXSrKBdetNVanSsyJBMtyosDzvgYMpKP4=
github.com/TicketsBot/common v0.0.0-20220609182514-8d43f86e8253/go.mod h1:ZAoYcDD7SQLTsZT7dbo/X0J256+pogVRAReunCGng+U= github.com/TicketsBot/common v0.0.0-20220615205931-a6a31e73b52a/go.mod h1:ZAoYcDD7SQLTsZT7dbo/X0J256+pogVRAReunCGng+U=
github.com/TicketsBot/database v0.0.0-20220616145240-1b6207291ca6 h1:lq5+CXNCQRUyd3ODq1Y6tUsEY7Y0e1YfLQr50C0Nuis= github.com/TicketsBot/database v0.0.0-20220621182433-accd1b2b81de h1:UsRiB3KIwqIF92huRBFKAnCoGLyT9kBYYUycsapBZk0=
github.com/TicketsBot/database v0.0.0-20220616145240-1b6207291ca6/go.mod h1:F57cywrZsnper1cy56Bx0c/HEsxQBLHz3Pl98WXblWw= github.com/TicketsBot/database v0.0.0-20220621182433-accd1b2b81de/go.mod h1:F57cywrZsnper1cy56Bx0c/HEsxQBLHz3Pl98WXblWw=
github.com/TicketsBot/database v0.0.0-20220616215313-0f5a33c3a2a6 h1:DC9CoT5uMuIh0pYX69euWLa/0MZLZA4sA+umIhOr0qo=
github.com/TicketsBot/database v0.0.0-20220616215313-0f5a33c3a2a6/go.mod h1:F57cywrZsnper1cy56Bx0c/HEsxQBLHz3Pl98WXblWw=
github.com/TicketsBot/database v0.0.0-20220618184239-b5ab901854fb h1:d9zo2sAW+EdZCWnkAiTKnCtH5urGZFwrntKv2F7Jdg8=
github.com/TicketsBot/database v0.0.0-20220618184239-b5ab901854fb/go.mod h1:F57cywrZsnper1cy56Bx0c/HEsxQBLHz3Pl98WXblWw=
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c h1:OqGjFH6mbE6gd+NqI2ARJdtH3UUvhiAkD0r0fhGJK2s= github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c h1:OqGjFH6mbE6gd+NqI2ARJdtH3UUvhiAkD0r0fhGJK2s=
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c/go.mod h1:jgi2OXQKsd5nUnTIRkwvPmeuD/i7OhN68LKMssuQY1c= github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c/go.mod h1:jgi2OXQKsd5nUnTIRkwvPmeuD/i7OhN68LKMssuQY1c=
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261 h1:NHD5GB6cjlkpZFjC76Yli2S63/J2nhr8MuE6KlYJpQM= github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261 h1:NHD5GB6cjlkpZFjC76Yli2S63/J2nhr8MuE6KlYJpQM=
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261/go.mod h1:2zPxDAN2TAPpxUPjxszjs3QFKreKrQh5al/R3cMXmYk= github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261/go.mod h1:2zPxDAN2TAPpxUPjxszjs3QFKreKrQh5al/R3cMXmYk=
github.com/TicketsBot/worker v0.0.0-20220614162334-f81bf3f39aa5 h1:c4bLQar8XH8cGK2nL2yUUP1bFoss0405QLG4MNeDoqY= github.com/TicketsBot/worker v0.0.0-20220621165800-203b0004b733 h1:G4iUjk4lgGRvbRCSJshpwuQetl+z3v7PmHzIW+HII9k=
github.com/TicketsBot/worker v0.0.0-20220614162334-f81bf3f39aa5/go.mod h1:kmap6C09BAbyqLqg8ZX+wDuNhbeZuSJbXwv3SvBtgtw= github.com/TicketsBot/worker v0.0.0-20220621165800-203b0004b733/go.mod h1:fhEqdxVhgXds/xB3ql05XSDqPLF4XWjkfyHr+JQFe0g=
github.com/apex/log v1.1.2 h1:bnDuVoi+o98wOdVqfEzNDlY0tcmBia7r4YkjS9EqGYk= github.com/apex/log v1.1.2 h1:bnDuVoi+o98wOdVqfEzNDlY0tcmBia7r4YkjS9EqGYk=
github.com/apex/log v1.1.2/go.mod h1:SyfRweFO+TlkIJ3DVizTSeI1xk7jOIIqOnUPZQTTsww= github.com/apex/log v1.1.2/go.mod h1:SyfRweFO+TlkIJ3DVizTSeI1xk7jOIIqOnUPZQTTsww=
github.com/apex/logs v0.0.3/go.mod h1:XzxuLZ5myVHDy9SAmYpamKKRNApGj54PfYLcFrXqDwo= github.com/apex/logs v0.0.3/go.mod h1:XzxuLZ5myVHDy9SAmYpamKKRNApGj54PfYLcFrXqDwo=
@ -264,8 +260,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/rxdn/gdl v0.0.0-20220614155333-7e6d7486acdd h1:lOwJSNyfd9Lyl5VKQDnv738x7//iZEkp8m277u27MVM= github.com/rxdn/gdl v0.0.0-20220621165443-28e214d254c1 h1:1/q9ohADLOrMQwhTfxRplPiMQ6EmVnJB+pWb+SLHd0c=
github.com/rxdn/gdl v0.0.0-20220614155333-7e6d7486acdd/go.mod h1:HtxfLp4OaoPoDJHQ4JOx/QeLH2d40VgT3wNOf7ETsRE= github.com/rxdn/gdl v0.0.0-20220621165443-28e214d254c1/go.mod h1:HtxfLp4OaoPoDJHQ4JOx/QeLH2d40VgT3wNOf7ETsRE=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/schollz/progressbar/v3 v3.8.2 h1:2kZJwZCpb+E/V79kGO7daeq+hUwUJW0A5QD1Wv455dA= github.com/schollz/progressbar/v3 v3.8.2 h1:2kZJwZCpb+E/V79kGO7daeq+hUwUJW0A5QD1Wv455dA=
github.com/schollz/progressbar/v3 v3.8.2/go.mod h1:9KHLdyuXczIsyStQwzvW8xiELskmX7fQMaZdN23nAv8= github.com/schollz/progressbar/v3 v3.8.2/go.mod h1:9KHLdyuXczIsyStQwzvW8xiELskmX7fQMaZdN23nAv8=