This commit is contained in:
Alicia 2019-02-24 14:56:23 +00:00
parent 95754bffef
commit 3f08657c4d

View File

@ -2,10 +2,10 @@ package v1
import (
"database/sql"
"github.com/osuYozora/api/common"
"sort"
"fmt"
"sort"
"strconv"
"github.com/osuYozora/common"
)
type singleClan struct {
@ -53,11 +53,11 @@ func ClansGET(md common.MethodData) common.CodeMessager {
return r
}
type clanMembersData struct {
common.ResponseBase
Members []userNotFullResponseLmao `json:"members"`
}
// get total stats of clan. later.
type totalStats struct {
common.ResponseBase
@ -115,7 +115,6 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
fmt.Println(brr)
m = 0
}
n := "std"
if m == 1 {
n = "taiko"
@ -198,9 +197,6 @@ func AllClanStatsGET(md common.MethodData) common.CodeMessager {
return r
}
func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
var (
r megaStats
@ -235,7 +231,7 @@ func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
//RETARD CODE HAHAAAA
m, brr := strconv.ParseInt(string(md.Query("m")[11]), 10, 64)
if brr != nil {
fmt.Printf("%v", brr)
fmt.Println(brr)
}
n := "std"
@ -248,6 +244,7 @@ func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
} else {
n = "std"
}
fmt.Println(n)
for i := 0; i < len(r.Clans); i++ {
var members clanMembersData
@ -271,7 +268,7 @@ func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
`, rid)
if err != nil {
fmt.Printf("%v", brr)
fmt.Println(err)
}
members.Code = 200
@ -321,7 +318,7 @@ func TotalClanStatsGET(md common.MethodData) common.CodeMessager {
})
for i := 0; i < len(r.Clans); i++ {
r.Clans[i].Rank = i+1
r.Clans[i].Rank = i + 1
}
b := totalStats{}
for i := 0; i < len(r.Clans); i++ {
@ -387,15 +384,23 @@ type imRetarded struct {
common.ResponseBase
Invite string `json:"invite"`
}
type adminClan struct {
Id int `json:"user"`
Perms int `json:"perms"`
}
func ClanInviteGET(md common.MethodData) common.CodeMessager {
// big perms check lol ok
n := common.Int(md.Query("id"))
adminRetard := adminClan{}
var r imRetarded
var clan int
// get user clan, then get invite
md.DB.QueryRow("SELECT clan FROM user_clans WHERE user = ? LIMIT 1", n).Scan(&clan)
md.DB.QueryRow("SELECT user, clan, perms FROM user_clans WHERE user = ? LIMIT 1", n).Scan(&adminRetard.Id, &clan, &adminRetard.Perms)
if adminRetard.Perms < 8 || adminRetard.Id != md.ID() {
return common.SimpleResponse(500, "You are not admin of there clan")
}
row := md.DB.QueryRow("SELECT invite FROM clans_invites WHERE clan = ? LIMIT 1", clan).Scan(&r.Invite)
if row != nil {
fmt.Println(row)