Documentation
¶
Index ¶
- Constants
- Variables
- func SendBanchoBotCommand[R interface{}](ctx context.Context, client *Client, command string, ...) (r *R, err error)
- func SendBanchoBotWhere(client *Client, u *User) (string, error)
- func TruncateString(str string, length int) string
- type BanchoBotStats
- type BaseMessage
- type Channel
- func (c *Channel) GetMember(username string) (*ChannelMember, bool)
- func (c *Channel) IsClient() bool
- func (c *Channel) Join() error
- func (c *Channel) Joined() bool
- func (c *Channel) Name() string
- func (c *Channel) Part() error
- func (c *Channel) Send(message string) error
- func (c *Channel) SendAction(message string) error
- func (c *Channel) Type() RecipientType
- type ChannelMember
- type ChannelMemberMode
- type ChannelMessage
- type Client
- func (c *Client) Connect() (err error)
- func (c *Client) GetChannel(channelName string) (channel *Channel, err error)
- func (c *Client) GetSelf() *User
- func (c *Client) GetUpdateChan(listenTypes []UpdateType, bufferSize ...int) chan *Update
- func (c *Client) GetUser(username string) (user *User)
- func (c *Client) IsConnected() bool
- func (c *Client) IsConnecting() bool
- func (c *Client) IsDisconnected() bool
- func (c *Client) IsReconnecting() bool
- func (c *Client) JoinChannel(channelName string) (channel *Channel, err error)
- func (c *Client) Quit() <-chan struct{}
- func (c *Client) SendRaw(format string, a ...any) error
- func (c *Client) Shutdown()
- type ClientOptions
- type ConnectState
- type Message
- type OutgoingMessage
- type PrivateMessage
- type Recipient
- type RecipientType
- type Update
- type UpdateType
- type User
- func (u *User) IsClient() bool
- func (u *User) Name() string
- func (u *User) Send(message string) error
- func (u *User) SendAction(message string) error
- func (u *User) Stats() (*BanchoBotStats, error)
- func (u *User) Type() RecipientType
- func (u *User) Where() (string, error)
- func (u *User) Whois() (*WhoisData, error)
- type UserData
- type WhoisData
- type WhoisUpdate
- type WhoisUpdateType
Constants ¶
View Source
const ( WHOIS_USER_ID = iota WHOIS_CHANNELS WHOIS_END )
View Source
const (
DEFAULT_BUFFER_SIZE = 1024
)
Variables ¶
View Source
var ( ErrChannelAlreadyJoined = errors.New("already joined") ErrChannelNotJoined = errors.New("you are not joined to this channel") )
View Source
var ( ErrMissingCredentials = errors.New("username or password field is empty string, please provide credentials") ErrBadAuthentication = errors.New("bancho authentication failed") ErrMessageTimeout = errors.New("Message timeout") ErrConnectionClosed = errors.New("connection closed") ErrConnectionTimeout = errors.New("connection timed out") ErrUserOffline = errors.New("user offline") ErrUserNotFound = errors.New("user not found") ErrChannelNotFound = errors.New("no such channel") )
View Source
var IrcHandlers = map[string]func(*Client, []string){
"001": handleWelcomeCommand,
"311": handleWhoisUserCommand,
"319": handleWhoisChannelsCommand,
"318": handleWhoisEndCommand,
"332": handleChannelTopicCommand,
"353": handleNamesCommand,
"403": handleChannelNotFoundCommand,
"464": handleBadAuthCommand,
"PRIVMSG": handlePrivmsgCommand,
"MODE": handleModeCommand,
"JOIN": handleJoinCommand,
"PART": handlePartCommand,
"QUIT": handleQuitCommand,
}
Functions ¶
func SendBanchoBotCommand ¶ added in v1.0.0
func SendBanchoBotWhere ¶ added in v1.0.0
func TruncateString ¶
Types ¶
type BanchoBotStats ¶ added in v1.0.0
type BanchoBotStats struct { UserId int Username string RankedScore int64 Rank int Level int PlayCount int Accuracy float64 Status string Online bool }
func SendBanchoBotStats ¶ added in v1.0.0
func SendBanchoBotStats(client *Client, u *User) (*BanchoBotStats, error)
SendBanchoBotStats sends !stats command to banchobot and returns SendBanchoBotStats FIXME: Make it concurrent safe
type BaseMessage ¶ added in v1.0.0
type BaseMessage struct { Date time.Time Sender Recipient User *User Self bool Message string // contains filtered or unexported fields }
func (*BaseMessage) Action ¶ added in v1.0.0
func (b *BaseMessage) Action() string
func (*BaseMessage) Author ¶ added in v1.0.0
func (b *BaseMessage) Author() *User
func (*BaseMessage) Content ¶ added in v1.0.0
func (b *BaseMessage) Content() string
func (*BaseMessage) From ¶ added in v1.0.0
func (b *BaseMessage) From() Recipient
func (*BaseMessage) Reply ¶ added in v1.0.0
func (b *BaseMessage) Reply(content string) error
func (*BaseMessage) ReplyAction ¶ added in v1.0.0
func (b *BaseMessage) ReplyAction(content string) error
func (*BaseMessage) String ¶ added in v1.0.0
func (b *BaseMessage) String() string
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
func SendBanchoBotMpMake ¶ added in v1.0.0
SendBanchoBotMpMake sends !mp make *name* to BanchoBot Join and return a #mp_* channel on success Returns error if banchoBot didn't respond after 20 seconds or couldn't create mp lobby
func (*Channel) GetMember ¶ added in v1.0.0
func (c *Channel) GetMember(username string) (*ChannelMember, bool)
func (*Channel) SendAction ¶
func (*Channel) Type ¶
func (c *Channel) Type() RecipientType
type ChannelMember ¶
type ChannelMember struct { Channel *Channel User *User Mode ChannelMemberMode }
type ChannelMemberMode ¶
type ChannelMemberMode string
const ( None ChannelMemberMode = "" IRCUser ChannelMemberMode = "v" IRCModerator ChannelMemberMode = "o" )
func (ChannelMemberMode) ToSymbol ¶
func (c ChannelMemberMode) ToSymbol() string
type ChannelMessage ¶
type ChannelMessage struct { *BaseMessage Channel *Channel }
type Client ¶
type Client struct { Username string Password string Host string Port string BotAccount bool //CacheUsers bool // TODO: UpdateBuffer int Users *xsync.MapOf[string, *User] Channels *xsync.MapOf[string, *Channel] RateLimiter ratelimit.Limiter // contains filtered or unexported fields }
func NewClient ¶ added in v1.0.0
func NewClient(opt ClientOptions) *Client
func (*Client) GetChannel ¶
func (*Client) GetUpdateChan ¶ added in v1.0.0
func (c *Client) GetUpdateChan(listenTypes []UpdateType, bufferSize ...int) chan *Update
func (*Client) IsConnected ¶
func (*Client) IsConnecting ¶
func (*Client) IsDisconnected ¶
func (*Client) IsReconnecting ¶
func (*Client) JoinChannel ¶ added in v1.0.0
type ClientOptions ¶
type ConnectState ¶
type ConnectState uint32
const ( Disconnected ConnectState = iota Reconnecting Connecting Connected )
func (ConnectState) String ¶ added in v1.0.0
func (s ConnectState) String() string
type OutgoingMessage ¶
type OutgoingMessage struct { Recipient Recipient Content string C chan error // contains filtered or unexported fields }
func (*OutgoingMessage) Send ¶
func (o *OutgoingMessage) Send() error
type PrivateMessage ¶
type PrivateMessage struct { *BaseMessage Recipient *User }
type RecipientType ¶ added in v1.0.0
type RecipientType uint8
const ( USER RecipientType = iota CHANNEL )
type Update ¶ added in v1.0.0
type Update struct { Type UpdateType Error error Raw string ConnectState *ConnectState RejectedMessage Message Message Message PrivateMessage *PrivateMessage ChannelMessage *ChannelMessage Whois *WhoisUpdate UserNotFound string ChannelNotFound string Join *ChannelMember Part *ChannelMember Quit *User }
type UpdateType ¶ added in v1.0.0
type UpdateType uint8
const ( ERROR UpdateType = iota RAW CONNECT_STATE REJECTED_MESSAGE MESSAGE PRIVATE_MESSAGE CHANNEL_MESSAGE WHOIS USER_NOT_FOUND CHANNEL_NOT_FOUND JOIN PART QUIT )
type User ¶
type User struct { UserData // contains filtered or unexported fields }
func (*User) SendAction ¶
func (*User) Stats ¶
func (u *User) Stats() (*BanchoBotStats, error)
func (*User) Type ¶
func (u *User) Type() RecipientType
type WhoisUpdate ¶ added in v1.0.0
type WhoisUpdate struct { Type WhoisUpdateType User *User UserId int Channels []*Channel }
type WhoisUpdateType ¶ added in v1.0.0
type WhoisUpdateType uint8
Click to show internal directories.
Click to hide internal directories.