-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.d.ts
940 lines (836 loc) · 25.8 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
declare module "bancho.js" {
import { EventEmitter } from "events";
import { RateLimiter } from "limiter";
import * as nodesu from "nodesu";
export class BanchoClient extends EventEmitter {
constructor(options: BanchoClientOptions)
/**
* Populated with a Nodesu client, if api key is passed to the constructor
*/
osuApi: nodesu.Client
/**
* Get a BanchoUser instance for the specified user
*/
getUser(username: string): BanchoUser
/**
* Get a BanchoUser representing ourself
*/
getSelf(): BanchoUser
/**
* Get a BanchoUser instance for the specified user id
*/
getUserById(userid: number): Promise<BanchoUser>
/**
* Get a BanchoChannel instance for the specified name
*/
getChannel(channelName: string): BanchoChannel|BanchoMultiplayerChannel
/**
* Creates a multiplayer lobby and return its channel.
* @param name Lobby name
* @param privateLobby Mark as private
*/
createLobby(name: string, private?: boolean): Promise<BanchoMultiplayerChannel>
/**
* Connects to Bancho, rejects an Error if connection fails
*/
connect(): Promise<null>
/**
* Disconnects from Bancho
*/
disconnect(): void
/**
* Returns the current connection state.
*/
getConnectState(): Symbol
/**
* Returns true if the connectState is Connected, false otherwise.
*/
isConnected(): boolean
/**
* Returns true if the connectState is Disconnected, otherwise false.
*/
isDisconnected(): boolean
/**
* Registers a listener for channel messages.
* @param listener the callback
*/
on(event: "CM", listener: (message: ChannelMessage) => void): this
/**
* Registers a listener for the successful connection events.
* @param listener the callback
*/
on(event: "connected", listener: () => void): this
/**
* Registers a listener for the disconnection events.
* @param listener the callback
*/
on(event: "disconnected", listener: (error: Error) => void): this
/**
* Registers a listener for errors.
* @param listener the callback
*/
on(event: "error", listener: (error: Error) => void): this
/**
* Registers a listener for when a user joins a channel.
* @param listener the callback
*/
on(event: "JOIN", listener: (member: BanchoChannelMember) => void): this
/**
* Registers a listener for when a user leaves a channel.
* @param listener the callback
*/
on(event: "PART", listener: (member: BanchoChannelMember) => void): this
/**
* Registers a listener for when the client fails to enter a non-existant channel.
* @param listener the callback with the concerned BanchoChannel
*/
on(event: "nochannel", listener: (channel: BanchoChannel) => void): this
/**
* Registers a listener for when the client tries to execute something for an offline user.
* @param listener the callback with the concerned BanchoUser
*/
on(event: "nouser", listener: (user: BanchoUser) => void): this
/**
* Registers a listener for private messages.
* @param listener the callback
*/
on(event: "PM", listener: (message: PrivateMessage) => void): this
/**
* Registers a listener for when Bancho sends us back a PM that couldn't be sent.
* As far as we know, only happens when a PM is rejected because the recipient blocks messages from non-friends.
* @param listener the callback with the concerned PrivateMessage
*/
on(event: "rejectedMessage", listener: (message: PrivateMessage) => void): this
/**
* Registers a listener for client state changes.
* @param listener the callback with a Symbol from ConnectStates and a possible error.
*/
on(event: "state", listener: (state: Symbol, error?: Error) => void): this
}
export class BanchoUser extends EventEmitter {
/**
* Creates an instance of BanchoUser.
* @param banchojs Bancho.js client this user was instancied by
*/
constructor(banchojs: BanchoClient, ircUsername: string)
banchojs: BanchoClient
ircUsername: string
id: number
username: string
joinDate: Date
count300: number
count100: number
count50: number
playcount: number
rankedScore: number
totalScore: number
ppRank: number
level: number
ppRaw: number
accuracy: number
countRankSS: number
countRankS: number
countRankA: number
country: number
totalSecondsPlayed: number
ppCountryRank: number
events: Array<nodesu.UserEvent>
/**
* Fetch the user from the osu! API if possible. Populates all the "optional" properties of BanchoUser.
*
* @throws {Error} osu! API/no API key error
*/
fetchFromAPI(): Promise<nodesu.User>
/**
* Returns true if the user is the client
*/
isClient(): boolean
/**
* Sends a PM to this user.
*/
sendMessage(message: string): Promise<null>
/**
* Sends an ACTION message to this user.
*/
sendAction(message: string): Promise<null>
/**
* Fires an IRC WHOIS request to the server about this user. Only works on online users.
* Throws if the user can't be found or is offline.
*/
whois(): Promise<BanchoWhoisReturn>
/**
* Fires a !where command to BanchoBot about this user. Only works on online users.
* Throws if the user can't be found or is offline.
*/
where(): Promise<string>
/**
* Fires a !stats command to BanchoBot about this user. Works on online and offline users.
* Will update the username, id, rankedScore, ppRank and playcount properties of this user.
* Status, levels and accuracy are stored in the returned object, as they are inaccurate data (missing decimals).
* It is recommended to get levels and accuracy by polling the osu! API instead.
* Throws if the user can't be found.
*/
stats(): Promise<BanchoBotStatsReturn>
/**
* Registers a listener for messages from this user
* @param listener the callback with the message
*/
on(event: "message", listener: (message: BanchoMessage) => void): this
}
/**
* Class describing what is returned after a WHOIS query on an online user
*/
export class BanchoWhoisReturn {
/**
* Username of the queried user
*/
name: string
/**
* User id of the queried user
*/
userid: number
/**
* Channels list the user is in
*/
channels: Array<BanchoChannel>
}
/**
* Contains properties returned by the BanchoBot !stats command that can't be set in BanchoUser.
*/
export class BanchoBotStatsReturn {
user: BanchoUser
/**
* Truncated value of levels (eg. 102)
*/
level: number
/**
* Rounded value of accuracy (eg. 98.83)
*/
accuracy: number
/**
* In-game status (eg. Afk, Idle, Playing...)
*/
status: string
/**
* Set to true if user is online *in-game*.
*/
online: boolean
}
/**
* Message to be sent later to a BanchoChannel or BanchoUser
*/
export class OutgoingBanchoMessage {
constructor(banchojs: BanchoClient, recipient: BanchoUser|BanchoChannel, message: string)
/**
* Sends the prepared message to the recipient
*
* @throws {Error} If recipient isn't a valid type
*/
send(): Promise<null>
recipient: BanchoUser|BanchoChannel
message: string
/**
* If target is considered public by Bancho. true if recipient is a channel and not a multiplayer channel
*/
isPublic: boolean
}
/**
* Represents a discussion channel (not including PMs)
*/
export class BanchoChannel extends EventEmitter {
/**
* @param name Channel name as it is referred by on IRC (including #)
*/
constructor(banchojs: BanchoClient, name: string)
/** Channel name as it is referred to on IRC (including #) */
name: string
topic: string
/** Members of the channel, referenced by their name */
channelMembers: Map<string, BanchoChannelMember>
/**
* Sends a message to this channel
*
* Elevated Bancho users are advised to heavily sanitize their inputs.
*/
sendMessage(message: string): Promise<null>
/**
* Sends an ACTION message to this channel
*/
sendAction(message: string): Promise<null>
join(): Promise<null>
leave(): Promise<null>
/**
* Registers a listener for messages in this channel
* @param listener the callback with the message
*/
on(event: "message", listener: (message: BanchoMessage) => void): this
/**
* Registers a listener for when a user joins this channel.
* @param listener the callback
*/
on(event: "JOIN", listener: (member: BanchoChannelMember) => void): this
/**
* Registers a listener for when a user leaves this channel.
* @param listener the callback
*/
on(event: "PART", listener: (member: BanchoChannelMember) => void): this
}
export class BanchoMultiplayerChannel extends BanchoChannel {
/**
* @param name Channel name as it is referred by on IRC (including #)
*/
constructor(banchojs: BanchoClient, name: string)
lobby: BanchoLobby
}
/**
* Represents a Bancho multiplayer lobby.
*
* Highly recommended to await updateSettings before manipulating (else some properties will be null).
*/
export class BanchoLobby extends EventEmitter {
channel: BanchoMultiplayerChannel
/**
* Multiplayer lobby ID (used in multiplayer history links)
*/
id: number
/**
* Multiplayer lobby ID (used in multiplayer history links)
*/
scores: Array<BanchoLobbyPlayerScore>
/**
* Name of the lobby, as seein in-game
*/
name: string
/**
* Array of BanchoLobbyPlayer determining each users' slot, from 0 to 15
*/
slots: Array<BanchoLobbyPlayer | null>
/**
* Current size of the lobby
*/
size: number
gamemode: nodesu.ModeType
/**
* Beatmap fetched from the API (late/not as reliable, use beatmapId when possible)
*
*/
beatmap: nodesu.Beatmap
beatmapId: number
/**
* See BanchoLobbyWinConditions
*/
winCondition: number
/**
* See BanchoLobbyTeamModes
*/
teamMode: number
mods: Array<BanchoMod>
freemod: boolean
/**
* Whether we're currently playing or not
*/
playing: boolean
/**
* Fetch lobby from the osu! API.
*/
fetchFromAPI(): Promise<nodesu.Multi>
/**
* Set a given map in the lobby
* @param map Either a beatmap ID or a Beatmap object from nodesu
* @param gamemode See nodesu.Mode. Defaults to current mode (osu! if undetected).
*/
setMap(map: number|nodesu.Beatmap, gamemode?: typeof nodesu.Mode[keyof typeof nodesu.Mode]): Promise<null>
/**
* Set given mods in the lobby
* @param mods Either an array of BanchoMods or a mods string joined by spaces
*/
setMods(mods: Array<BanchoMod>|string, freemod?: boolean): Promise<null>
/**
* Sets the lobby's name
*/
setName(name: string): Promise<null>
/**
* Sets the lobby's password
*/
setPassword(password: string): Promise<null>
/**
* Adds referees to the lobby
* @param ref A string or array of strings of referee(s) to add, referenced by their usernames or #<userid>
*/
addRef(ref: Array<string>|string): Promise<null>
/**
* Removes referees from the lobby
* @param ref A string or array of strings of referee(s) to remove, referenced by their usernames or #<userid>
*/
removeRef(ref: Array<string>|string): Promise<null>
/**
* Locks the lobby's slots and teams
*/
lockSlots(): Promise<null>
/**
* Unlocks the lobby's slots and teams
*/
unlockSlots(): Promise<null>
/**
* Set the amount of open slots in the lobby
*/
setSize(size: number): Promise<null>
/**
* Sets the settings of the lobby
* @param teamMode See BanchoLobbyTeamModes
* @param winCondition See BanchoLobbyWinConditions
*/
setSettings(teamMode?: number, winCondition?: number, size?: number): Promise<null>
/**
* Moves a player from one slot to another
* @param slot starting from 0
*/
movePlayer(player: BanchoLobbyPlayer, slot: number): Promise<null>
/**
* Invites a player to the lobby
* @param player Referenced by their username or #<userid>
*/
invitePlayer(player: string): Promise<null>
/**
* Sets a player as the host of the lobby
* @param player Referenced by their username or #<userid>
*/
setHost(player: string): Promise<null>
/**
* Kicks a player from the lobby
* @param player Referenced by their username or #<userid>
*/
kickPlayer(player: string): Promise<null>
/**
* Bans a player from the lobby
* @param player Referenced by their username or #<userid>
*/
banPlayer(player: string): Promise<null>
/**
* Get back the host from one's hand
*/
clearHost(): Promise<null>
/**
* Close the lobby
*/
closeLobby(): Promise<null>
/**
* Start the match
*/
startMatch(timeout?: number): Promise<null>
/**
* Start a timer
*/
startTimer(timeout: number): Promise<null>
/**
* Abort an ongoing timer
*/
abortTimer(): Promise<null>
/**
* Abort the match
*/
abortMatch(): Promise<null>
/**
* Change one's team
* @param team See BanchoLobbyTeams
*/
changeTeam(player: BanchoLobbyPlayer, team: string): Promise<null>
/**
* Fires !mp settings, updates properties and player slots
*/
updateSettings(): Promise<null>
/**
* Gets the player who is currently host
*/
getHost(): BanchoLobbyPlayer
/**
* Gets the slot of a player
*/
getPlayerSlot(player: BanchoLobbyPlayer): number
/**
* Gets or instanciate a player by its username
*/
getPlayerByName(name: string): Promise<BanchoLobbyPlayer>
/**
* Gets or instanciate a player by its userid
*/
getPlayerById(id: number): Promise<BanchoLobbyPlayer>
/**
* Gets the mp link or however you name it.
*/
getHistoryUrl(): string
/**
* Sort scores by pass and score.
*/
sortScores(): void
on(event: "allPlayersReady", listener: () => void): this
/**
* Fired when the beatmap property is updated from the API
*/
on(event: "beatmap", listener: (beatmap: nodesu.Beatmap) => void): this
/**
* Fired when the beatmapId is updated
*/
on(event: "beatmapId", listener: (beatmapId: number) => void): this
/**
* Fired when the lobby's freemod property is updated
*/
on(event: "freemod", listener: (freemod: boolean) => void): this
on(event: "gamemode", listener: (gamemode: typeof nodesu.Mode[keyof typeof nodesu.Mode]) => void): this
on(event: "host", listener: (player: BanchoLobbyPlayer) => void): this
on(event: "hostCleared", listener: () => void): this
on(event: "invalidBeatmapId", listener: () => void): this
on(event: "matchAborted", listener: () => void): this
on(event: "matchFinished", listener: () => void): this
on(event: "slotsLocked", listener: () => void): this
on(event: "slotsUnlocked", listener: () => void): this
on(event: "matchSettings", listener: (settings: {
size: number
teamMode: number
winCondition: number
}) => void): this
on(event: "size", listener: (size: number) => void): this
on(event: "matchStarted", listener: () => void): this
on(event: "mods", listener: (mods: Array<BanchoMod>) => void): this
on(event: "name", listener: (name: string) => void): this
on(event: "passwordChanged", listener: () => void): this
on(event: "passwordRemoved", listener: () => void): this
on(event: "playerChangedTeam", listener: (obj: {
player: BanchoLobbyPlayer
team: string
}) => void): this
on(event: "playerJoined", listener: (obj: {
player: BanchoLobbyPlayer
slot: number
team: string
}) => void): this
on(event: "playerMoved", listener: (obj: {
player: BanchoLobbyPlayer
slot: number
}) => void): this
on(event: "playerLeft", listener: (player: BanchoLobbyPlayer) => void): this
/**
* Fired when the lobby starts or stop playing
*/
on(event: "playing", listener: (playing: boolean) => void): this
on(event: "refereeAdded", listener: (username: string) => void): this
on(event: "refereeRemoved", listener: (username: string) => void): this
/**
* Fired when the slots of the lobby are updated
*/
on(event: "slots", listener: (player: BanchoLobbyPlayer) => void): this
on(event: "teamMode", listener: (teamMode: number) => void): this
on(event: "winCondition", listener: (winCondition: number) => void): this
on(event: "userNotFound", listener: () => void): this
on(event: "userNotFoundUsername", listener: (username: string) => void): this
on(event: "timerEnded", listener: () => void): this
on(event: "timerAborted", listener: () => void): this
on(event: "timerTick", listener: (seconds: number) => void): this
on(event: "startTimerStarted", listener: (seconds: number) => void): this
on(event: "startTimerAborted", listener: () => void): this
on(event: "startTimerTick", listener: (seconds: number) => void): this
}
export class BanchoLobbyPlayer {
lobby: BanchoLobby
user: BanchoUser
/**
* ready/not ready/no map, see BanchoLobbyPlayerState
*/
state: Symbol
isHost: boolean
/**
* Blue or Red, see BanchoLobbyTeams
*/
team: string
mods: Array<BanchoMod>
score: BanchoLobbyPlayerScore
}
export class BanchoLobbyPlayerScore {
score: number
pass: boolean
player: BanchoLobbyPlayer
}
export class BanchoMod {
enumValue: number
shortMod: string
longMod: string
}
/**
* A Bancho channel user mode, or "IRC modes".
* Used by Bancho to mark someone in a channel as an IRC user or a moderator.
*/
export class BanchoChannelMemberMode {
/**
* @param ircLetter Letter used in the MODE command to represent this mode
* @param name Name to describe the mode
*/
constructor(ircLetter: string, name: string)
}
/** A Bancho channel member */
export class BanchoChannelMember {
/**
* @param client
* @param channel
* @param userString Username with optional @ or + prefix (that will automatically determine the role)
*/
constructor(client: BanchoClient, channel: BanchoChannel, userString: string)
channel: BanchoChannel
user: BanchoUser
mode: BanchoChannelMemberMode
}
/**
* Bancho incoming message
*/
export class BanchoMessage {
user: BanchoUser
message: string
self: boolean
readonly content: string
/**
* Tries to parse this message as an ACTION (/me message).
*/
getAction(): string | undefined;
}
/**
* The type for channel messages.
*/
export class ChannelMessage extends BanchoMessage {
channel: BanchoChannel
}
/**
* The type for private messages.
*/
export class PrivateMessage extends BanchoMessage {
recipient: BanchoUser
}
/**
* Static class with a property for each mods and methods to manipulate them
*/
type BanchoModsTypes = {
None: BanchoMod
NoFail: BanchoMod
Easy: BanchoMod
Hidden: BanchoMod
HardRock: BanchoMod
SuddenDeath: BanchoMod
DoubleTime: BanchoMod
Relax: BanchoMod
HalfTime: BanchoMod
Nightcore: BanchoMod
Flashlight: BanchoMod
Autoplay: BanchoMod
SpunOut: BanchoMod
Relax2: BanchoMod
Perfect: BanchoMod
Key4: BanchoMod
Key5: BanchoMod
Key6: BanchoMod
Key7: BanchoMod
Key8: BanchoMod
FadeIn: BanchoMod
Random: BanchoMod
LastMod: BanchoMod
Key9: BanchoMod
Key10: BanchoMod
Key1: BanchoMod
Key3: BanchoMod
Key2: BanchoMod
enum: {
None: BanchoMod
NoFail: BanchoMod
Easy: BanchoMod
Hidden: BanchoMod
HardRock: BanchoMod
SuddenDeath: BanchoMod
DoubleTime: BanchoMod
Relax: BanchoMod
HalfTime: BanchoMod
Nightcore: BanchoMod
Flashlight: BanchoMod
Autoplay: BanchoMod
SpunOut: BanchoMod
Relax2: BanchoMod
Perfect: BanchoMod
Key4: BanchoMod
Key5: BanchoMod
Key6: BanchoMod
Key7: BanchoMod
Key8: BanchoMod
FadeIn: BanchoMod
Random: BanchoMod
LastMod: BanchoMod
Key9: BanchoMod
Key10: BanchoMod
Key1: BanchoMod
Key3: BanchoMod
Key2: BanchoMod
}
/**
* Parse mods in their bit flags form and returns them in an array of BanchoMods.
* @param bits Mods combination in bit flags form
* @param returnNone Returns [BanchoMods.None] if bits is equal to 0
*/
parseBitFlags(bits: number, returnNone?: boolean): BanchoMod[]
/**
* Returns a bits flag integer representing the passed mods.
*/
returnBitFlags(mods: BanchoMod[]): number
/**
* Parse a mod in its short form (eg. HD). Case insensitive.
*/
parseShortMod(shortMod: string): BanchoMod
/**
* Parse a short mods combination as a string or array of strings.
* @param shortMods Accepted string formats: "HDDT", "HD, DT", "HD DT". The amount of spaces doesn't matter. Allowed seperators are comma and spaces.
*/
parseShortMods(shortMods: string|string[]): BanchoMod[]
/**
* Parse a mod in its long form (eg. Hidden). Case insensitive.
*/
parseLongMod(longMod: string): BanchoMod
/**
* Parse a long mods combination as a string or array of strings.
* @param longMods Accepted string formats: "Hidden, DoubleTime", "Hidden DoubleTime". The amount of spaces doesn't matter. Allowed seperators are comma and spaces.
*/
parseLongMods(longMods: string|string[]): BanchoMod[]
}
interface BanchoClientBaseOptions {
/**
* Username of the user to connect to Bancho
*/
username: string,
/**
* IRC Password of the user to connect to Bancho (see https://osu.ppy.sh/p/irc)
*/
password: string,
/**
* Custom IRC host (for proxy-ing from a firewall for example)
*/
host?: string,
/**
* Custom IRC port
*/
port?: number,
/**
* osu! API key for API requests (see https://osu.ppy.sh/p/api). WARNING: Multiplayer lobbies won't work without an API key!
*/
apiKey?: string,
/**
* Gamemode id to fetch users with. Defaults to null
*/
gamemode?: number
}
interface BanchoClientOptionsWithoutRateLimiter extends BanchoClientBaseOptions {
rateLimiter?: never
botAccount?: never
limiterTimespan?: never
limiterPrivate?: never
}
interface BanchoClientOptionsWithRateLimiter extends BanchoClientBaseOptions {
/**
* Instance of RateLimiter from the `limiter` npm module for outgoing Bancho messages. Default is safe for normal users in private messages (PM and #multiplayer channels), bots are not supposed to send public messages. Can be disabled by setting to `null`.
*/
rateLimiter: RateLimiter
botAccount?: never
limiterTimespan?: never
limiterPrivate?: never
}
interface BanchoClientOptionsBotAccount extends BanchoClientBaseOptions {
/**
* Apply bot account rate-limits to the default RateLimiter instance if true (see https://osu.ppy.sh/wiki/en/Bot_account).
*/
botAccount: boolean
rateLimiter?: never
limiterTimespan?: never
limiterPrivate?: never
}
interface BanchoClientOptionsDeprecated extends BanchoClientBaseOptions {
/**
* Span of milliseconds in you may not exceed the following limits. Default *should* be safe for normal users, recommended value for chat bot accounts is 60000.
* @deprecated
*/
limiterTimespan: number,
/**
* Amount of private messages (PMs & messages in multiplayer channels) you allow the bot to send in the last timespan. Default *should* be safe for normal users, recommended value for chat bot accounts is 270 (300 * 0.9, 10% margin to protect from accuracy issues, because of bancho/network).
* @deprecated
*/
limiterPrivate: number
rateLimiter?: never
botAccount?: never
}
/**
* Options for a BanchoClient.
*/
type BanchoClientOptions = BanchoClientOptionsWithoutRateLimiter | BanchoClientOptionsWithRateLimiter | BanchoClientOptionsBotAccount | BanchoClientOptionsDeprecated;
type BanchoLobbyPlayerStatesTypes = {
Ready: Symbol,
NotReady: Symbol,
"Not Ready": Symbol
NoMap: Symbol,
"No Map": Symbol
}
type BanchoLobbyTeamModesTypes = {
HeadToHead: number,
TagCoop: number,
TeamVs: number,
TagTeamVs: number
}
type BanchoLobbyTeamsTypes = {
Blue: string
Red: string
}
type BanchoLobbyWinConditionsTypes = {
Score: number,
Accuracy: number,
Combo: number,
ScoreV2: number
}
/**
* Contains the different connect states: Disconnected, Connecting, Reconnecting, Connected.
*/
type ConnectStateTypes = {
/**
* When we're purposely disconnected from Bancho or after an auth fail
*/
Disconnected: Symbol,
/**
* When we've opened the socket before any reconnection attempts and waiting for the Welcome packet
*/
Connecting: Symbol,
/**
* When we've gotten disconnected, and are currently waiting before trying to reconnect
*/
Reconnecting: Symbol,
/**
* When we're online! \o/
*/
Connected: Symbol
}
/** Compares the provided object and return true if the object is an instance of BanchoMod. */
export function isBanchoMod(mod: BanchoMod): boolean
/** Compares the provided object and return true if the object is an instance of BanchoUser. */
export function isBanchoUser(user: BanchoUser): boolean
/** Compares the provided object and return true if the object is an instance of BanchoChannel. */
export function isBanchoChannel(channel: BanchoChannel): boolean
/** Compares the provided object and return true if the object is an instance of BanchoMultiplayerChannel. */
export function isBanchoMultiplayerChannel(channel: BanchoMultiplayerChannel): boolean
/** Compares the provided object and return true if the object is an instance of BanchoLobby. */
export function isBanchoLobby(lobby: BanchoLobby): boolean
/** Compares the provided object and return true if the object is an instance of BanchoChannelMember. */
export function isBanchoChannelMember(member: BanchoChannelMember): boolean
/** Compares the provided object and return true if the object is an instance of BanchoMessage. */
export function isBanchoMessage(message: BanchoMessage): boolean
/** Compares the provided object and return true if the object is an instance of ChannelMessage. */
export function isChannelMessage(message: ChannelMessage): boolean
/** Compares the provided object and return true if the object is an instance of PrivateMessage. */
export function isPrivateMessage(message: PrivateMessage): boolean
/**
* Contains the different connect states: Disconnected, Connecting, Reconnecting, Connected.
*/
export const BanchoLobbyPlayerStates: BanchoLobbyPlayerStatesTypes
export const BanchoLobbyTeamModes: BanchoLobbyTeamModesTypes
export const BanchoLobbyTeams: BanchoLobbyTeamsTypes
export const BanchoLobbyWinConditions: BanchoLobbyWinConditionsTypes
export const BanchoMods: BanchoModsTypes
export const ConnectStates: ConnectStateTypes
}