nx

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2024 License: MIT Imports: 12 Imported by: 0

README

nx

A command-line toolkit and Go library for Habbo Hotel.

Installation

To install the command-line toolkit

go install xabbo.io/nx/cmd/nx@latest

Usage

User
Retrieve a user's information
$ nx user xb7c
             Name │ xb7c
           Status │ Offline
      Last access │ 1 January 2024 3:08:53 am (6 days ago)
        Unique ID │ hhus-c09969403c0b73332345a4b0165ef300
          Created │ 11 November 2023 3:01:19 am
           Figure │ hr-3090-42.hd-180-1.ch-3110-64-1408.lg-275-64.ha-1003-64
            Motto │ (no motto)
  Selected badges │ (none)
From another hotel
$ nx user --hotel nl b7c
             Name │ b7c
           Status │ Offline
      Last access │ 12 December 2022 1:58:01 am (1 year ago)
        Unique ID │ hhnl-f4f6928d744d06d4c81aa61116606d25
          Created │ 7 July 2020 6:45:49 am
           Figure │ hr-3090-42.hd-180-1.ch-3110-64-1408.lg-275-64.ha-1003-64
            Motto │ (no motto)
  Selected badges │ (none)

You can also set the HOTEL environment variable so you don't need to specify --hotel all the time.

$ export HOTEL=nl
$ nx user b7c
             Name │ b7c
           Status │ Offline
      Last access │ 12 December 2022 1:58:01 am (1 year ago)
        Unique ID │ hhnl-f4f6928d744d06d4c81aa61116606d25
          Created │ 7 July 2020 6:45:49 am
           Figure │ hr-3090-42.hd-180-1.ch-3110-64-1408.lg-275-64.ha-1003-64
            Motto │ (no motto)
  Selected badges │ (none)
Outputting the raw JSON response
$ nx user xb7c --json
{"uniqueId":"hhus-c09969403c0b73332345a4b0165ef300","name":"xb7c","figureString":"hr-3090-42.hd-180-1.ch-3110-64-1408.
lg-275-64.ha-1003-64","motto":"","online":false,"lastAccessTime":"2024-01-03T02:08:53.000+0000","memberSince":"2023-11
-08T14:01:19.000+0000","profileVisible":true,"currentLevel":4,"currentLevelCompletePercent":20,"totalExperience":48,"s
tarGemCount":2,"selectedBadges":[]}
$ nx user xb7c --json | jq .totalExperience
48
Furni
Search for furni
$ nx furni search dragon lamp
Forest Dragon Lamp [rare_dragonlamp*5]
Emerald Dragon Lamp [rare_colourable_dragonlamp*2]
Duck Blue Dragon Lamp [rare_colourable_dragonlamp*5]
Azure Dragon Lamp [rare_colourable_dragonlamp*1]
Bronze Dragon Lamp [rare_dragonlamp*8]
Pink Dragon Lamp [rare_dragonlamp_pink]
Teal Dragon Lamp [rare_colourable_dragonlamp*3]
Rose Gold Dragon Lamp [rare_blackrosegold_dragonlamp]
Bliss Dragon Lamp [nft_ff23_v7_dragon_bliss]
Rainbow Dragon Lamp LTD [rainbow_ltd21_dragonlamp]
Sky Dragon Lamp [rare_dragonlamp*7]
Brown Dragon Lamp [rare_colourable_dragonlamp*4]
Silver Dragon Lamp [rare_dragonlamp*3]
Blue Dragon Lamp [rare_dragonlamp*1]
Diamond Dragon Lamp [diamond_dragon]
Black Dragon Lamp [rare_dragonlamp*4]
Fire Dragon Lamp [rare_dragonlamp*0]
Maroon Dragon Lamp [rare_dragonlamp*10]
Show furni info
$ nx furni info 'rare_colourable_dragonlamp*1'
               Name │ Azure Dragon Lamp
        Description │ Scary and scorching!
         Identifier │ rare_colourable_dragonlamp*1
               Type │ Floor
               Kind │ 9136
           Revision │ 69009
               Line │ rare
        Environment │
           Category │ other
  Default direction │ 4
               Size │ 1 x 1
        Part colors │ [#FFFFFF #13ABEA #13ABEA #FFFFFF #FFFFFF #FFFFFF #FFFFFF]
           Offer ID │ -1
             Buyout │ false
                 BC │ false
   Excluded dynamic │ false
      Custom params │
       Special type │ 1
       Can stand on │ false
         Can sit on │ false
         Can lay on │ false
Figure
Show figure info
By user name
$ nx figure info -u xb7c
hr-3090-42.hd-180-1.ch-3110-64-1408.lg-275-64.ha-1003-64
┌─ Hair (hr)
│  └─ 3090
├─ Face & Body (hd)
│  └─  180
├─ Shirts (ch)
│  └─ 3110
├─ Trousers (lg)
│  └─  275
└─ Hats (ha)
   └─ 1003
By figure string

With parts, colors and clothing furni identifiers

$ nx figure info -pci hr-4090-61.hd-180-1.ch-3934-110-110.lg-3596-110-110.ea-3978-110-110.cc-4184-110-110
┌─ Hair (hr)
│  ├─ 4090: Middle Part Hair [clothing_middlepart]
│  │  ├─ hr-4023 [hair_U_middlepart]
│  │  └─ hrb-4023 [hair_U_middlepart]
│  └─   61: #2d2d2d
├─ Face & Body (hd)
│  ├─  180
│  │  ├─ bd-1 [hh_human_body]
│  │  ├─ ey-1 [hh_human_face]
│  │  ├─ fc-1 [hh_human_face]
│  │  ├─ hd-2 [hh_human_body]
│  │  ├─ lh-1 [hh_human_body]
│  │  └─ rh-1 [hh_human_body]
│  └─    1: #ffcb98
├─ Shirts (ch)
│  ├─ 3934: Macho Tattoo [clothing_r20_tattoo]
│  │  ├─ ch-3633 [shirt_M_tattoo]
│  │  ├─ ls-3633 [shirt_M_tattoo]
│  │  ├─ rs-3633 [shirt_M_tattoo]
│  │  ├─ ch-3634 [shirt_M_tattoo]
│  │  ├─ ls-3634
│  │  └─ rs-3634
│  ├─  110: #1e1e1e
│  └─  110: #1e1e1e
├─ Trousers (lg)
│  ├─ 3596: Harem Pants [clothing_harempants]
│  │  ├─ lg-3005 [trousers_U_harempants]
│  │  └─ lg-3006 [trousers_U_harempants]
│  ├─  110: #1e1e1e
│  └─  110: #1e1e1e
├─ Goggles (ea)
│  ├─ 3978: Sleep Time [clothing_r20_slumberoutfit]
│  │  ├─ ea-3720 [acc_eye_U_sleepingmask]
│  │  └─ ea-3721 [acc_eye_U_sleepingmask]
│  ├─  110: #1e1e1e
│  └─  110: #1e1e1e
└─ Jackets (cc)
   ├─ 4184: Kimono by -Push, [clothing_r21_kimono3]
   │  ├─ cc-4218 [jacket_U_kimono3a]
   │  ├─ lc-4218 [jacket_U_kimono3a]
   │  ├─ rc-4218 [jacket_U_kimono3a]
   │  ├─ cc-4219 [jacket_U_kimono3a]
   │  ├─ lc-4219
   │  └─ rc-4219
   ├─  110: #1e1e1e
   └─  110: #1e1e1e
Imager
Avatars
nx img avatar -u Strawberry

Strawberry-std-ntr-2-2

You can also render a figure string directly: nx img avatar hr-3090-42.hd-180-1.ch-3110-64-1408.lg-275-64.ha-1003-64

Furni
Static
nx img furni club_sofa -d 2

club_sofa_64_2_0_0_0 1

All directions
nx img duck -D

Screenshot_2024-11-07_03 06 21

All states
nx img furni autumn_c20_bench -S

Screenshot_2024-11-07_03 10 11

All colors
nx img furni 'rare_colourable_dragonlamp*1' -C

Screenshot_2024-11-07_03 12 32

Animated
nx img furni stellar_c23_galaxydragon -d 2 -f gif

stellar_c23_galaxydragon_64_2_0_0 816

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound = errors.New("the user was not found")
	ErrUserBanned   = errors.New("the user is banned")
	ErrMaintenance  = errors.New("the server is under maintenance")
)

AvatarActions contains all of the avatar states that are actions.

AvatarExpressions contains all of the avatar states that are expressions.

Functions

This section is empty.

Types

type ApiClient

type ApiClient struct {
	Http *http.Client
	Host string
	// Issue an extra request to determine if a user who is not found previously existed,
	// indicating that they have been permanently banned.
	// If so, the error returned will be ErrUserBanned.
	CheckBan bool
	Agent    string // The user agent to use.
}

func NewApiClient

func NewApiClient(host string) *ApiClient

func (*ApiClient) GetProfile

func (c *ApiClient) GetProfile(uid HabboId) (profile web.Profile, err error)

func (*ApiClient) GetRawUser

func (c *ApiClient) GetRawUser(name string) (data []byte, err error)

Gets the raw response of the specified user's info.

func (*ApiClient) GetUser

func (c *ApiClient) GetUser(uid HabboId) (user web.User, err error)

Gets a user's information by their unique HabboId.

func (*ApiClient) GetUserByName

func (c *ApiClient) GetUserByName(name string) (user web.User, err error)

Gets a user's information by their name. If the user was not found, and CheckBan is true, an extra request will be issued to determine whether the user exists and was not found due to being permanently banned.

func (*ApiClient) GetUserExists

func (c *ApiClient) GetUserExists(name string) (exists bool, err error)

Checks if a user exists by sending a HEAD request to the avatar imaging API. This can determine whether a user exists even if their profile is not found due to being permanently banned.

type AvatarState

type AvatarState string

AvatarState defines an action or expression of an avatar.

const (
	ActStand    AvatarState = "std"     // Standing.
	ActWalk     AvatarState = "wlk"     // Walking.
	ActWave     AvatarState = "wav"     // Waving.
	ActLay      AvatarState = "lay"     // Laying.
	ActBlowKiss AvatarState = "blw"     // Blowing a kiss.
	ActCarry    AvatarState = "crr"     // Carrying a hand item.
	ActDrink    AvatarState = "drk"     // Drinking.
	ActRespect  AvatarState = "respect" // Respecting.
	ActSign     AvatarState = "sig"     // Showing a sign.
	ActSit      AvatarState = "sit"     // Sitting.
)
const (
	// ExprNeutral is used to specify a neutral or no expression.
	// It is not an official expression, and is not included in AllExpressions.
	ExprNeutral      AvatarState = "ntr"
	ExprSpeak        AvatarState = "spk" // Speaking.
	ExprSleep        AvatarState = "eyb" // Sleeping.
	ExprSad          AvatarState = "sad" // Sad.
	ExprSmile        AvatarState = "sml" // Smiling.
	ExprAngry        AvatarState = "agr" // Angry.
	ExprSurprised    AvatarState = "srp" // Surprised.
	ExprSpeakLay     AvatarState = "lsp" // Speaking / laying.
	ExprSleepLay     AvatarState = "ley" // Sleeping / laying.
	ExprSadLay       AvatarState = "lsa" // Sad / laying.
	ExprSmileLay     AvatarState = "lsm" // Smiling / laying.
	ExprAngryLay     AvatarState = "lag" // Angry / laying.
	ExprSurprisedLay AvatarState = "lsr" // Surprised / laying.
)

func (AvatarState) IsAction

func (state AvatarState) IsAction() bool

IsAction reports whether the avatar state is an action.

func (AvatarState) IsExpression

func (state AvatarState) IsExpression() bool

IsExpression reports whether the avatar state is an expression.

type Figure

type Figure struct {
	Gender Gender
	Items  []FigureItem
}

A Figure represents a gender and a set of figure items.

func (*Figure) Parse

func (f *Figure) Parse(figure string) (err error)

Parse parses a figure string into a Figure.

func (*Figure) String

func (f *Figure) String() string

String formats the figure to its string representation.

type FigureItem

type FigureItem struct {
	Type   FigurePartType // The type of figure part set.
	Id     int            // The identifier of the figure part set.
	Colors []int          // A list of color identifiers.
}

FigureItem defines a figure part set type and identifier with colors.

func (*FigureItem) String

func (item *FigureItem) String() string

String formats the figure item to its string representation.

type FigurePart

type FigurePart struct {
	Type FigurePartType // The type of the figure part.
	Id   int            // The identifier of the figure part.
}

A FigurePart defines a figure part type and identifier.

func (*FigurePart) String

func (part *FigurePart) String() string

String formats the figure part to its string representation.

type FigurePartType

type FigurePartType string
const (
	Hair          FigurePartType = "hr"  // Hair.
	HairBelow     FigurePartType = "hrb" // Hair below hat.
	Head          FigurePartType = "hd"  // Head.
	Hat           FigurePartType = "ha"  // Hat.
	HeadAcc       FigurePartType = "he"  // Head accessory.
	EyeAcc        FigurePartType = "ea"  // Eye accessory, i.e. glasses.
	FaceAcc       FigurePartType = "fa"  // Face accessory, i.e. masks.
	Eyes          FigurePartType = "ey"  // Eyes.
	Face          FigurePartType = "fc"  // Face.
	Body          FigurePartType = "bd"  // Body.
	LeftHand      FigurePartType = "lh"  // Left hand.
	RightHand     FigurePartType = "rh"  // Right hand.
	Chest         FigurePartType = "ch"  // Chest, i.e. shirts.
	ChestPrint    FigurePartType = "cp"  // Chest print.
	ChestAcc      FigurePartType = "ca"  // Chest accessory, i.e. jewellery.
	LeftSleeve    FigurePartType = "ls"  // Left sleeve.
	RightSleeve   FigurePartType = "rs"  // Right sleeve.
	Legs          FigurePartType = "lg"  // Legs, i.e. trousers.
	Shoes         FigurePartType = "sh"  // Shoes.
	Waist         FigurePartType = "wa"  // Waist, i.e. belts.
	Coat          FigurePartType = "cc"  // Coat/jacket.
	LeftCoat      FigurePartType = "lc"  // Left coat sleeve.
	RightCoat     FigurePartType = "rc"  // Right coat sleeve.
	LeftHandItem  FigurePartType = "li"  // Left hand item.
	RightHandItem FigurePartType = "ri"  // Right hand item.
)

func (FigurePartType) Flip

func (pt FigurePartType) Flip() FigurePartType

Flip flips the part type between left and right arms, if it is an arm part. If not, the part type is returned unchanged.

func (FigurePartType) IsBody

func (pt FigurePartType) IsBody() bool

IsBody reports whether the part type belongs to the body.

func (FigurePartType) IsHead

func (pt FigurePartType) IsHead() bool

IsHead reports whether the part type belongs to the head.

func (FigurePartType) IsLeftArm

func (pt FigurePartType) IsLeftArm() bool

IsLeftArm reports whether the part type belongs to the left arm.

func (FigurePartType) IsRightArm

func (pt FigurePartType) IsRightArm() bool

IsRightArm reports whether the part type belongs to the right arm.

func (FigurePartType) IsWearable

func (layer FigurePartType) IsWearable() (wearable bool)

IsWearable reports whether the figure part type is valid in a figure string.

type FurniType

type FurniType int

FurniType represents the special type of a furni.

const (
	FurniTypeNormal FurniType = iota + 1
	FurniTypeWallpaper
	FurniTypeFloor
	FurniTypeLandscape
	FurniTypeSticky
	FurniTypePoster
	FurniTypeTrax
	FurniTypeDisk
	FurniTypeGift
	FurniTypeMysteryBox
	FurniTypeTrophy
	FurniTypeHorseDye FurniType = iota + 2
	FurniTypeHorseHairstyle
	FurniTypeHorseHairdye
	FurniTypeHorseSaddle
	FurniTypeGroup
	FurniTypeSnowWar
	FurniTypeMonsterPlantSeed
	FurniTypeMonsterPlantRevival
	FurniTypeMonsterPlantRebreeding
	FurniTypeMonsterPlantFertiliser
	FurniTypeClothing
)

type Gender

type Gender string
const (
	Male   Gender = "M"
	Female Gender = "F"
	Unisex Gender = "U"
)

type HabboId

type HabboId struct {
	// The type of the identifier.
	Kind HabboIdKind
	// The hotel identifier.
	Hotel string
	// A 128-bit unique identifier.
	Uid [16]byte
}

A HabboId is unique Habbo resource identifier.

func (*HabboId) Parse

func (id *HabboId) Parse(s string) (err error)

func (*HabboId) String

func (id *HabboId) String() string

type HabboIdKind

type HabboIdKind int

HabboIdKind represents the kind of resource identified, i.e. user, group or room.

const (
	HabboIdKindUser HabboIdKind = iota
	HabboIdKindGroup
	HabboIdKindRoom
)

func (HabboIdKind) Prefix

func (t HabboIdKind) Prefix() string

type ItemType

type ItemType rune

ItemType represents the type of an item. May be floor, wall, badge, effect or bot.

const (
	// Represents a floor item type.
	ItemFloor ItemType = 's'
	// Represents a wall item type.
	ItemWall ItemType = 'i'
	// Represents a badge item type.
	ItemBadge ItemType = 'b'
	// Represents an effect item type.
	ItemEffect ItemType = 'e'
	// Represents a bot item type.
	ItemBot ItemType = 'r'
)

func (ItemType) MarshalJSON

func (t ItemType) MarshalJSON() ([]byte, error)

func (ItemType) String

func (t ItemType) String() string

String returns the name of the item type.

Directories

Path Synopsis
cmd
nx
Package gamedata provides types for the following game data:
Package gamedata provides types for the following game data:
Package imager provides functionality for rendering assets to images.
Package imager provides functionality for rendering assets to images.
raw
Package raw contains sub-packages for parsing raw JSON and XML assets.
Package raw contains sub-packages for parsing raw JSON and XML assets.
json
Package json provides types for parsing raw JSON assets.
Package json provides types for parsing raw JSON assets.
nitro
Package nitro provides functionality for reading Nitro assets.
Package nitro provides functionality for reading Nitro assets.
xml
Package xml provides types for parsing XML assets.
Package xml provides types for parsing XML assets.
Package res provides functionality for loading resources from figure part and furni libraries.
Package res provides functionality for loading resources from figure part and furni libraries.
Package web provides types for parsing JSON responses from the web API.
Package web provides types for parsing JSON responses from the web API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL