Update vendor

This commit is contained in:
itzaname 2023-03-05 20:21:43 -05:00
parent b60a4e0a37
commit 5c7c02d4a4
11 changed files with 457 additions and 4 deletions

2
go.mod
View File

@ -3,7 +3,7 @@ module git.itzana.me/itzaname/rbxcompiler
go 1.15
require (
git.itzana.me/itzaname/go-roblox v1.0.1
git.itzana.me/itzaname/go-roblox v0.0.0-20211231223654-d84bfb7ebaab
git.itzana.me/itzaname/rbxfile v0.0.0-20210811000911-6fc7a2281e8d
github.com/google/uuid v1.1.2
)

4
go.sum
View File

@ -1,5 +1,5 @@
git.itzana.me/itzaname/go-roblox v1.0.1 h1:kWcuw/Kbds9ppbqs8sAI403AyScd7ntt0N7qZiOtEY8=
git.itzana.me/itzaname/go-roblox v1.0.1/go.mod h1:x+fEejcurT8y/Vq+/ErqDHZm04d9lmYDGxjGpcPvJW4=
git.itzana.me/itzaname/go-roblox v0.0.0-20211231223654-d84bfb7ebaab h1:Gq506+Kw+tpUZGcgK9nR3dnr8z+2yFb6O3UccFY9Asg=
git.itzana.me/itzaname/go-roblox v0.0.0-20211231223654-d84bfb7ebaab/go.mod h1:x+fEejcurT8y/Vq+/ErqDHZm04d9lmYDGxjGpcPvJW4=
git.itzana.me/itzaname/rbxapi v0.1.0 h1:tmIGSKSgy2dEuKKar8/uyUgMvcBxq7VxXL5U8+SPJes=
git.itzana.me/itzaname/rbxapi v0.1.0/go.mod h1:xLmFDqsHxDbA841GccVxiK8IIpgciymGMgZB3dzeXsM=
git.itzana.me/itzaname/rbxfile v0.0.0-20210811000911-6fc7a2281e8d h1:K9qkm1OlnTpKR7jBRYu1lI/Wr7zbTCOYHrWkP1GhnzQ=

2
vendor/git.itzana.me/itzaname/go-roblox/.gitignore generated vendored Normal file
View File

@ -0,0 +1,2 @@
.vscode/launch.json
debug

1
vendor/git.itzana.me/itzaname/go-roblox/README.md generated vendored Normal file
View File

@ -0,0 +1 @@
Copyright © Stuart Livingston

104
vendor/git.itzana.me/itzaname/go-roblox/asset.go generated vendored Normal file
View File

@ -0,0 +1,104 @@
package roblox
import (
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
)
type AssetUploadOptions struct {
Name string
AssetID int
Description string
Public bool
Comments bool
Group int
}
type AssetUploadResponse struct {
AssetID int64 `json:"AssetId"`
AssetVersionID int64 `json:"AssetVersionId"`
}
func (s *Session) CreateAsset(options *AssetUploadOptions, f io.Reader) (int, error) {
endpoint, err := url.Parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1")
if err != nil {
return -1, err
}
query := endpoint.Query()
query.Set("name", options.Name)
query.Set("description", options.Description)
query.Set("assetid", strconv.Itoa(options.AssetID))
// Comments
if options.Comments {
query.Set("allowComments", "true")
} else {
query.Set("allowComments", "false")
}
// Public
if options.Public {
query.Set("ispublic", "true")
} else {
query.Set("ispublic", "false")
}
// Group
if options.Group > 0 {
query.Set("groupId", strconv.Itoa(options.Group))
}
endpoint.RawQuery = query.Encode()
req, err := http.NewRequest("POST", endpoint.String(), nil)
req.Header.Set("user-agent", "Roblox")
// Perform request
resp, err := s.client.Do(req)
if err != nil {
return -1, err
}
defer resp.Body.Close()
if resp.StatusCode == 403 && resp.Header.Get("X-Csrf-Token") != "" {
req, err := http.NewRequest("POST", endpoint.String(), f)
req.Header.Set("user-agent", "Roblox")
req.Header.Set("x-csrf-token", strings.Trim(resp.Header["X-Csrf-Token"][0], " "))
// Perform request
resp, err = s.client.Do(req)
if err != nil {
return -1, err
}
defer resp.Body.Close()
}
if resp.StatusCode != 200 {
return -1, fmt.Errorf(resp.Status)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return -1, err
}
return strconv.Atoi(string(body))
}
func (s *Session) Download(id int) (io.Reader, error) {
resp, err := s.client.Get("https://assetgame.roblox.com/Asset/?id=" + strconv.Itoa(id))
if err != nil {
return nil, err
}
if resp.StatusCode != 200 {
return nil, fmt.Errorf(resp.Status)
}
return resp.Body, nil
}

3
vendor/git.itzana.me/itzaname/go-roblox/go.mod generated vendored Normal file
View File

@ -0,0 +1,3 @@
module git.itzana.me/itzaname/go-roblox
go 1.15

156
vendor/git.itzana.me/itzaname/go-roblox/item.go generated vendored Normal file
View File

@ -0,0 +1,156 @@
package roblox
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
)
// Item struct containing data on retrieved items
type Item struct {
ProductID int
ItemID int
AssetID int
UserID int
UserName string
Type string
Name string
CopyLocked bool
Owned bool
}
// HasItem will return if you own the item
func (s *Session) HasItem(id int) (bool, error) {
resp, err := s.client.Get(fmt.Sprintf("http://api.roblox.com/Ownership/HasAsset?userId=%d&assetId=%d", s.ID, id))
if err != nil {
return false, err
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return false, err
}
return string(data) == "true", nil
}
// AddItem add item by id to inventory
func (s *Session) AddItem(id int) error {
product, err := s.GetProduct(id)
if err != nil {
return err
}
payload := struct {
ExpectedCurrency int `json:"expectedCurrency"`
ExpectedPrice int `json:"expectedPrice"`
ExpectedSellerID int `json:"expectedSellerId"`
}{
ExpectedCurrency: 1,
ExpectedPrice: 0,
ExpectedSellerID: product.Creator.ID,
}
// Gen json body
data, err := json.Marshal(&payload)
if err != nil {
return err
}
req, err := http.NewRequest("POST", fmt.Sprintf("https://economy.roblox.com/v1/purchases/products/%d", product.ProductID), bytes.NewBuffer(data))
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
resp, err := s.client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 403 {
req, err := http.NewRequest("POST", fmt.Sprintf("https://economy.roblox.com/v1/purchases/products/%d", product.ProductID), bytes.NewBuffer(data))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Csrf-Token", resp.Header["X-Csrf-Token"][0])
resp, err := s.client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("Failed to add item. Status %d", resp.StatusCode)
}
}
return nil
}
// RemoveItem will remove item from inventory
func (s *Session) RemoveItem(id int) error {
v := url.Values{}
v.Set("assetId", strconv.Itoa(id))
resp, err := s.client.Post("https://www.roblox.com/asset/delete-from-inventory", "application/x-www-form-urlencoded", bytes.NewBufferString(v.Encode()))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 403 {
req, err := http.NewRequest("POST", "https://www.roblox.com/asset/delete-from-inventory", bytes.NewBufferString(v.Encode()))
req.Header.Set("x-csrf-token", strings.Trim(resp.Header["X-Csrf-Token"][0], " "))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := s.client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("Failed to remove item. Status %d", resp.StatusCode)
}
}
return nil
}
// GetModels will list models in inventory
func (s *Session) GetModels(user int) ([]Item, error) {
var Data []Item
resp, err := s.client.Get("https://www.roblox.com/users/inventory/list-json?assetTypeId=10&userId=" + strconv.Itoa(user))
if err != nil {
return Data, fmt.Errorf("Could not get list: %s", err)
}
if resp.StatusCode == 200 {
var dat map[string]interface{}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
if err := json.Unmarshal(body, &dat); err != nil {
panic(err)
}
set := dat["Data"].(map[string]interface{})
ilist := set["Items"].([]interface{})
for _, obj := range ilist {
itm := obj.(map[string]interface{})
iInfo := itm["Item"].(map[string]interface{})
iCreator := itm["Creator"].(map[string]interface{})
Data = append(Data, Item{0, int(iInfo["AssetId"].(float64)), 0, int(iCreator["Id"].(float64)), iCreator["Name"].(string), "Model", iInfo["Name"].(string), false, true})
}
return Data, nil
}
return Data, fmt.Errorf("Could not get models. Status: %d", resp.StatusCode)
}

61
vendor/git.itzana.me/itzaname/go-roblox/product.go generated vendored Normal file
View File

@ -0,0 +1,61 @@
package roblox
import (
"encoding/json"
"fmt"
"io/ioutil"
"time"
)
// Product contains info about a product
type Product struct {
TargetID int `json:"TargetId"`
ProductType string `json:"ProductType"`
AssetID int `json:"AssetId"`
ProductID int `json:"ProductId"`
Name string `json:"Name"`
Description string `json:"Description"`
AssetTypeID int `json:"AssetTypeId"`
Creator struct {
ID int `json:"Id"`
Name string `json:"Name"`
CreatorType string `json:"CreatorType"`
CreatorTargetID int `json:"CreatorTargetId"`
} `json:"Creator"`
IconImageAssetID int `json:"IconImageAssetId"`
Created time.Time `json:"Created"`
Updated time.Time `json:"Updated"`
PriceInRobux int `json:"PriceInRobux"`
PriceInTickets int `json:"PriceInTickets"`
Sales int `json:"Sales"`
IsNew bool `json:"IsNew"`
IsForSale bool `json:"IsForSale"`
IsPublicDomain bool `json:"IsPublicDomain"`
IsLimited bool `json:"IsLimited"`
IsLimitedUnique bool `json:"IsLimitedUnique"`
Remaining int `json:"Remaining"`
MinimumMembershipLevel int `json:"MinimumMembershipLevel"`
ContentRatingTypeID int `json:"ContentRatingTypeId"`
}
// GetProduct will retrieve store information on a product
func (s *Session) GetProduct(id int) (*Product, error) {
resp, err := s.client.Get(fmt.Sprintf("http://api.roblox.com/marketplace/productinfo?assetId=%d", id))
if err != nil {
return nil, err
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var info Product
err = json.Unmarshal(data, &info)
if err != nil {
return nil, err
}
return &info, nil
}

89
vendor/git.itzana.me/itzaname/go-roblox/session.go generated vendored Normal file
View File

@ -0,0 +1,89 @@
package roblox
import (
"fmt"
"net/http"
"net/http/cookiejar"
"net/url"
)
// Session struct for roblox login session data and members
type Session struct {
ID int
Username string
client *http.Client
}
// New create a new session and logs in with provided data
func New(cookie string) (*Session, error) {
cookieJar, _ := cookiejar.New(nil)
rbxCookie := []*http.Cookie{&http.Cookie{
Name: ".ROBLOSECURITY",
Value: cookie,
}}
// url.Parse("http://www.roblox.com") // http://api.roblox.com
cookieJar.SetCookies(&url.URL{Scheme: "http", Host: "www.roblox.com"}, rbxCookie)
cookieJar.SetCookies(&url.URL{Scheme: "http", Host: "api.roblox.com"}, rbxCookie)
cookieJar.SetCookies(&url.URL{Scheme: "https", Host: "economy.roblox.com"}, rbxCookie)
cookieJar.SetCookies(&url.URL{Scheme: "https", Host: "data.roblox.com"}, rbxCookie)
client := &http.Client{
Jar: cookieJar,
}
session := Session{0, "", client}
/*err := session.Login(username, password)
if err != nil {
return nil, fmt.Errorf("Failed to login: %s", err)
}*/
info, err := session.GetUserInfo()
if err != nil {
return nil, fmt.Errorf("Failed to retrieve user information: %s", err)
}
session.ID = info.UserID
session.Username = info.UserName
return &session, err
}
/*func (s *Session) Login(username, password string) error {
details := struct {
Ctype string `json:"ctype"`
Cvalue string `json:"cvalue"`
Password string `json:"password"`
}{
"Username",
username,
password,
}
payload, err := json.Marshal(&details)
if err != nil {
return err
}
resp, err := s.client.Post("https://auth.roblox.com/v2/login", "application/json", bytes.NewBuffer(payload))
if err != nil {
return err
}
resp.Body.Close()
if resp.StatusCode == 403 {
req, err := http.NewRequest("POST", "https://auth.roblox.com/v2/login", bytes.NewBuffer(payload))
req.Header.Set("X-Csrf-Token", resp.Header["X-Csrf-Token"][0])
req.Header.Set("Content-Type", "application/json")
resp, err := s.client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("Status %d", resp.StatusCode)
}
}
return nil
}*/

37
vendor/git.itzana.me/itzaname/go-roblox/user.go generated vendored Normal file
View File

@ -0,0 +1,37 @@
package roblox
import (
"encoding/json"
"io/ioutil"
)
type UserInfo struct {
UserID int `json:"UserID"`
UserName string `json:"UserName"`
RobuxBalance int `json:"RobuxBalance"`
TicketsBalance int `json:"TicketsBalance"`
ThumbnailURL string `json:"ThumbnailUrl"`
IsAnyBuildersClubMember bool `json:"IsAnyBuildersClubMember"`
}
// GetUserInfo will retrieve local user information
func (s *Session) GetUserInfo() (*UserInfo, error) {
resp, err := s.client.Get("http://www.roblox.com/mobileapi/userinfo")
if err != nil {
return nil, err
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var info UserInfo
err = json.Unmarshal(data, &info)
if err != nil {
return nil, err
}
return &info, nil
}

2
vendor/modules.txt vendored
View File

@ -1,4 +1,4 @@
# git.itzana.me/itzaname/go-roblox v1.0.1
# git.itzana.me/itzaname/go-roblox v0.0.0-20211231223654-d84bfb7ebaab
## explicit
git.itzana.me/itzaname/go-roblox
# git.itzana.me/itzaname/rbxapi v0.1.0