mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-09-10 21:12:30 +00:00
.github
bridge
ci
contrib
docker
gateway
hook
matterclient
matterhook
vendor
github.com
42wim
BurntSushi
GeertJohan
Philipp15b
go-steam
community
cryptoutil
dota
economy
generator
gsbot
jsont
netutil
protocol
rwu
socialcache
steamid
tf2
trade
tradeoffer
client.go
error.go
escrow.go
receipt.go
tradeoffer.go
LICENSE.txt
auth.go
auth_events.go
client.go
client_events.go
connection.go
doc.go
gamecoordinator.go
keys.go
notifications.go
notifications_events.go
servers.go
social.go
social_events.go
steam_directory.go
trading.go
trading_events.go
web.go
web_events.go
alecthomas
armon
bwmarrin
coreos
daaku
davecgh
dgrijalva
facebookgo
fsnotify
go-telegram-bot-api
golang
google
gorilla
hashicorp
jpillora
kardianos
kr
labstack
lrstanley
magiconair
matrix-org
matterbridge
mattermost
mattn
mgutz
mitchellh
mreiferson
mrexodia
nicksnyder
nlopes
paulrosania
pborman
pelletier
peterhellberg
pkg
russross
saintfish
satori
shazow
shurcooL
sirupsen
sorcix
spf13
stretchr
technoweenie
tylerb
valyala
x-cray
xordataexchange
zfjagann
golang.org
gopkg.in
manifest
.travis.yml
Dockerfile
LICENSE
README.md
changelog.md
matterbridge.go
matterbridge.toml.sample
matterbridge.toml.simple
36 lines
791 B
Go
36 lines
791 B
Go
package tradeoffer
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"github.com/Philipp15b/go-steam/economy/inventory"
|
|
"regexp"
|
|
)
|
|
|
|
type TradeReceiptItem struct {
|
|
AssetId uint64 `json:"id,string"`
|
|
AppId uint32
|
|
ContextId uint64
|
|
Owner uint64 `json:",string"`
|
|
Pos uint32
|
|
inventory.Description
|
|
}
|
|
|
|
func parseTradeReceipt(data []byte) ([]*TradeReceiptItem, error) {
|
|
reg := regexp.MustCompile("oItem =\\s+(.+?});")
|
|
itemMatches := reg.FindAllSubmatch(data, -1)
|
|
if itemMatches == nil {
|
|
return nil, fmt.Errorf("items not found\n")
|
|
}
|
|
items := make([]*TradeReceiptItem, 0, len(itemMatches))
|
|
for _, m := range itemMatches {
|
|
item := new(TradeReceiptItem)
|
|
err := json.Unmarshal(m[1], &item)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, item)
|
|
}
|
|
return items, nil
|
|
}
|