C# Class Squishy.Irc.IrcClient

Representing a fully working Irc connection class. Extend and override the sufficient OnEvent methods in order to customize it. The Dcc class offers sufficient events and commands for dealing with all Dcc matters.
ファイルを表示 Open project: jaddie/WCell-Utility-Bot Class Usage Examples

Public Properties

Property Type Description
Info string
Network IrcNetworkInfo
Privileges Privilege[]
ServerPassword string
WhiteSpace System.Text.RegularExpressions.Regex

Protected Properties

Property Type Description
m_CommandHandler Squishy.Irc.Commands.IrcCommandHandler
m_MaxNickLen int
protHandler Squishy.Irc.Protocol.IrcProtocolHandler

Public Methods

Method Description
BeginConnect ( string addr ) : void
BeginConnect ( string addr, int port ) : void

Saves the sufficient information and lets the Client instance start to connect to a Server. It will not connect if it is already connected or currently connecting. (Use Disconnect first in that case) When the Client connected successfully it dumps its ThrottledSendQueue.

GetChannel ( string name ) : IrcChannel
GetOrCreateChannel ( string name ) : IrcChannel

Gets the channel with the current name or creates a new Channel object, if it doesn't exist yet

GetOrCreateUser ( string mask ) : IrcUser
GetPrivForFlag ( char flag ) : Privilege
GetSymbolForFlag ( char flag ) : char

Returns the symbol for the specified flag ("@" would usually be the symbol for "o" e.g.).

GetUser ( string nick ) : IrcUser
GetUsers ( string mask ) : Squishy.Irc.IrcUser[]

Loops through all Users to find those who match the given mask.

HasChanMode ( string modes ) : bool

Indicates wether or not the current Irc Network offers the specified Channel modes - Independent on the sequence.

IrcClient ( ) : System
IrcClient ( Encoding encoding ) : System
IsOn ( string channame ) : bool

Indicates wether or not this IrcClient is on the Channel with the specified name.

MayTriggerCommand ( CmdTrigger cmdTrigger ) : bool

Return wether or not a command may be triggered. Is called everytime, a command is triggered.

MayTriggerCommand ( CmdTrigger trigger, Command cmd ) : bool

Return wether or not a command may be triggered. Is called everytime, a command is triggered.

Send ( string text ) : void

Uses the Client.Send(string) to enqueue the corresponding text into the ThrottledSendQueue.

SendNow ( string text ) : void

Uses the Client.SendNow(text) to send a line of text immediately to the server.

SupportsSymbols ( string symbols ) : bool

Indicates wether or not the current Irc 4rk supports the specified Channel symbols (such as @,+ etc) - Independent on the sequence.

TriggersCommand ( IrcUser user, IrcChannel chan, Squishy.Network.StringStream input ) : bool

Protected Methods

Method Description
OnBanListComplete ( IrcChannel chan ) : void

Fires when the BanList for a Channel has been sent completely.

OnBanListEntry ( IrcChannel chan, BanEntry entry ) : void

Fires when an already established BanEntry has been sent (raw 367).

OnBeforeSend ( string text ) : void

Fires when something is sent by the Client. (When Client.SendNow(string) is called.)

OnCannotJoin ( IrcChannel chan, string reason ) : void
OnChanCreationTime ( IrcChannel chan, System.DateTime creationTime ) : void

Fires when the CreationTime of a Channel has been sent (raw 329)

OnChannelMsg ( IrcUser user, IrcChannel chan, Squishy.Network.StringStream text ) : void

Fires when the Client receives a PRIVMSG which was directed to a Channel.

OnCommandFail ( CmdTrigger trigger, Exception ex ) : void

Fires when a Command raises an Exception while being executed.

OnConnectFail ( Exception ex ) : void

Fires when the Client raises the specified Exception during the Connect process.

OnConnected ( ) : void

Fires when the Client instance of this IrcClient established a connection with a server.

OnConnecting ( ) : void

Is called when the Client instance connects to a new server.

OnConnectionInfo ( IrcPacket packet, string>.Dictionary pairs ) : void

Fires when network-specific Informations are sent (raw 005).

OnCtcpReply ( IrcUser user, IrcChannel chan, string reply, string args ) : void

Fires when the Client receives any kind of CTCP reply.

OnCtcpRequest ( IrcUser user, IrcChannel chan, string request, string args ) : void

Fires when the Client receives any kind of CTCP request. Automatically replies to the VERSION request with the content of the Version variable if not overridden.

OnDisconnected ( bool conLost ) : void

Fires when the Client disconnected.

OnError ( IrcPacket packet ) : void

Fires when an Error reply has been sent by the network (raw is greater than 399).

OnExceptionRaised ( Exception e ) : void

Fires when an exception is raised during the protocol handling.

OnFlagAdded ( IrcUser user, IrcChannel chan, Privilege priv, IrcUser target ) : void

Fires when a User adds a Channel flag to another User.

OnFlagDeleted ( IrcUser user, IrcChannel chan, Privilege priv, IrcUser target ) : void

Fires when a User deletes a Channel flag from another User.

OnInvalidNick ( string err, string nick, string args ) : void

Fires when a chosen nick is already in use.

OnInvite ( IrcUser user, string chan ) : void

Fires when the specified User sends an invitation for the specified Channel.

OnJoin ( IrcUser user, IrcChannel chan ) : void

Fires when the specified User joins the specified Channel.

OnKick ( IrcUser from, IrcChannel chan, IrcUser target, string reason ) : void

Fires when a User is kicked from a Channel.

OnModeAdded ( IrcUser user, IrcChannel chan, string mode, string param ) : void

Fires when a User adds a Channel mode.

OnModeDeleted ( IrcUser user, IrcChannel chan, string mode, string param ) : void

Fures when a User deletes a Channel mode.

OnNick ( IrcUser user, string oldNick, string newNick ) : void

Fires when a User has changed the nick.

OnNotice ( IrcUser user, IrcChannel chan, Squishy.Network.StringStream text ) : void

Fires when the Client receives any kind of NOTICE.

OnPart ( IrcUser user, IrcChannel chan, string reason ) : void

Fires when a User parts from a Channel.

OnQueryMsg ( IrcUser user, Squishy.Network.StringStream text ) : void

Fires when the Client receives a PRIVMSG, directed to this Client itself.

OnQuit ( IrcUser user, string reason ) : void

Fires when a User quits.

OnText ( IrcUser user, IrcChannel chan, Squishy.Network.StringStream text ) : void

Fires when the Client receives any kind of PRIVMSG or NOTICE.

OnTopic ( IrcUser user, IrcChannel chan, string text, bool initial ) : void

Fires when the Topic for a Channel has been sent. Either when joining a Channel or when modified by a User.

OnUnknownCommandUsed ( CmdTrigger trigger ) : void

Fires when the aliasing engine cannot find a command. Sends the command to the Server when not overridden.

OnUnspecifiedInfo ( IrcPacket packet ) : void

Fires when an information is sent that is not captured by the intern protocol handler.

OnUserDisappeared ( IrcUser user ) : void

Called whenever a User quits or parts all common Channels

OnUserEncountered ( IrcUser user ) : void
OnUserLeftChannel ( IrcChannel chan, IrcUser user, string reason ) : void

Fires when a user is kicked from or parts from a channel or quits.

OnUserModeChanged ( ) : void

Fires when own Usermodes have been changed.

OnUsersAdded ( IrcChannel chan, IrcUser users ) : void

Fires when the Client receives the Names list for the specified Channel.

OnWhoReply ( string channame, string username, string host, string server, string nick, string flags, string hops, string info ) : void

Fires when the Client receives a Who-reply (raw 352).

Perform ( ) : void

Fires when the Client is fully logged on the network and the End of Motd is sent (raw 376).

Private Methods

Method Description
AuthNotify ( IrcUser user ) : void
BanListCompleteNotify ( IrcChannel chan ) : void
BanListEntryNotify ( IrcChannel chan, BanEntry entry ) : void
BeforeSendNotify ( string text ) : void
CannotJoinNotify ( IrcChannel channel, string reason ) : void
ChanCreationTimeNotify ( IrcChannel chan, System.DateTime creationTime ) : void
ChannelMsgNotify ( IrcUser user, IrcChannel chan, Squishy.Network.StringStream text ) : void
CheckUserKnown ( IrcUser user ) : void
CommandFailNotify ( CmdTrigger trigger, Exception ex ) : void
ConnectFailNotify ( Exception ex ) : void
ConnectNotify ( ) : void
ConnectingNotify ( ) : void
ConnectionInfoNotify ( IrcPacket packet ) : void
CtcpReplyNotify ( IrcUser user, IrcChannel chan, string reply, string args ) : void
CtcpRequestNotify ( IrcUser user, IrcChannel chan, string request, string text ) : void
DisconnectNotify ( bool conLost ) : void
ErrorNotify ( IrcPacket packet ) : void
ExceptionNotify ( Exception e ) : void
FlagAddedNotify ( IrcUser user, IrcChannel chan, Privilege priv, IrcUser target ) : void
FlagDeletedNotify ( IrcUser user, IrcChannel chan, Privilege priv, IrcUser target ) : void
InvalidNickNotify ( string err, string nick, string args ) : void
InviteNotify ( IrcUser user, string chan ) : void
JoinNotify ( IrcUser user, string name ) : void
KickNotify ( IrcUser user, IrcChannel chan, IrcUser target, string reason ) : void
ModeAddedNotify ( IrcUser user, IrcChannel chan, string mode, string param ) : void
ModeDeletedNotify ( IrcUser user, IrcChannel chan, string mode, string param ) : void
NickNotify ( IrcUser user, string newNick ) : void
NoticeNotify ( IrcUser user, IrcChannel chan, Squishy.Network.StringStream text ) : void
OnUserParsed ( IrcUser user ) : void
PartNotify ( IrcUser user, IrcChannel chan, string reason ) : void
PerformNotify ( ) : void
QueryMsgNotify ( IrcUser user, Squishy.Network.StringStream text ) : void
QuitNotify ( IrcUser user, string reason ) : void
Reset ( ) : void
TextNotify ( IrcUser user, IrcChannel chan, Squishy.Network.StringStream text ) : void
TopicNotify ( IrcUser user, IrcChannel chan, string text, bool initial ) : void
UnkownCommandUsedNotify ( CmdTrigger trigger ) : void
UnspecifiedInfoNotify ( IrcPacket packet ) : void
UserLeftChannelNotify ( IrcChannel chan, IrcUser user, string reason ) : void
UserModeChangedNotify ( ) : void
UsersAddedNotify ( IrcChannel chan, IrcUser users ) : void
WhoReplyNotify ( string channame, string username, string host, string server, string nick, string flags, string hops, string info ) : void

Method Details

BeginConnect() public method

public BeginConnect ( string addr ) : void
addr string
return void

BeginConnect() public method

Saves the sufficient information and lets the Client instance start to connect to a Server. It will not connect if it is already connected or currently connecting. (Use Disconnect first in that case) When the Client connected successfully it dumps its ThrottledSendQueue.
public BeginConnect ( string addr, int port ) : void
addr string The address where the Client should connect to
port int The port on the Server where the Client should connect to
return void

GetChannel() public method

public GetChannel ( string name ) : IrcChannel
name string The case-insensitive Channel name.
return IrcChannel

GetOrCreateChannel() public method

Gets the channel with the current name or creates a new Channel object, if it doesn't exist yet
public GetOrCreateChannel ( string name ) : IrcChannel
name string The case-insensitive Channel name.
return IrcChannel

GetOrCreateUser() public method

public GetOrCreateUser ( string mask ) : IrcUser
mask string
return IrcUser

GetPrivForFlag() public method

public GetPrivForFlag ( char flag ) : Privilege
flag char
return Privilege

GetSymbolForFlag() public method

Returns the symbol for the specified flag ("@" would usually be the symbol for "o" e.g.).
public GetSymbolForFlag ( char flag ) : char
flag char
return char

GetUser() public method

public GetUser ( string nick ) : IrcUser
nick string The case-insensitive User'str nick.
return IrcUser

GetUsers() public method

Loops through all Users to find those who match the given mask.
public GetUsers ( string mask ) : Squishy.Irc.IrcUser[]
mask string The mask of the users that are to be found.
return Squishy.Irc.IrcUser[]

HasChanMode() public method

Indicates wether or not the current Irc Network offers the specified Channel modes - Independent on the sequence.
public HasChanMode ( string modes ) : bool
modes string A sequence of chars, representing Channel modes
return bool

IrcClient() public method

public IrcClient ( ) : System
return System

IrcClient() public method

public IrcClient ( Encoding encoding ) : System
encoding System.Text.Encoding
return System

IsOn() public method

Indicates wether or not this IrcClient is on the Channel with the specified name.
public IsOn ( string channame ) : bool
channame string
return bool

MayTriggerCommand() public method

Return wether or not a command may be triggered. Is called everytime, a command is triggered.
public MayTriggerCommand ( CmdTrigger cmdTrigger ) : bool
cmdTrigger Squishy.Irc.Commands.CmdTrigger
return bool

MayTriggerCommand() public method

Return wether or not a command may be triggered. Is called everytime, a command is triggered.
public MayTriggerCommand ( CmdTrigger trigger, Command cmd ) : bool
trigger Squishy.Irc.Commands.CmdTrigger
cmd Squishy.Irc.Commands.Command A command.
return bool

OnBanListComplete() protected method

Fires when the BanList for a Channel has been sent completely.
protected OnBanListComplete ( IrcChannel chan ) : void
chan IrcChannel
return void

OnBanListEntry() protected method

Fires when an already established BanEntry has been sent (raw 367).
protected OnBanListEntry ( IrcChannel chan, BanEntry entry ) : void
chan IrcChannel
entry BanEntry
return void

OnBeforeSend() protected method

Fires when something is sent by the Client. (When Client.SendNow(string) is called.)
protected OnBeforeSend ( string text ) : void
text string The line of text which is supposed to be sent.
return void

OnCannotJoin() protected method

protected OnCannotJoin ( IrcChannel chan, string reason ) : void
chan IrcChannel
reason string
return void

OnChanCreationTime() protected method

Fires when the CreationTime of a Channel has been sent (raw 329)
protected OnChanCreationTime ( IrcChannel chan, System.DateTime creationTime ) : void
chan IrcChannel
creationTime System.DateTime
return void

OnChannelMsg() protected method

Fires when the Client receives a PRIVMSG which was directed to a Channel.
protected OnChannelMsg ( IrcUser user, IrcChannel chan, Squishy.Network.StringStream text ) : void
user IrcUser
chan IrcChannel
text Squishy.Network.StringStream
return void

OnCommandFail() protected method

Fires when a Command raises an Exception while being executed.
protected OnCommandFail ( CmdTrigger trigger, Exception ex ) : void
trigger Squishy.Irc.Commands.CmdTrigger
ex System.Exception
return void

OnConnectFail() protected method

Fires when the Client raises the specified Exception during the Connect process.
protected OnConnectFail ( Exception ex ) : void
ex System.Exception
return void

OnConnected() protected method

Fires when the Client instance of this IrcClient established a connection with a server.
protected OnConnected ( ) : void
return void

OnConnecting() protected method

Is called when the Client instance connects to a new server.
protected OnConnecting ( ) : void
return void

OnConnectionInfo() protected method

Fires when network-specific Informations are sent (raw 005).
protected OnConnectionInfo ( IrcPacket packet, string>.Dictionary pairs ) : void
packet Squishy.Irc.Protocol.IrcPacket
pairs string>.Dictionary A Dictionary, containing all information, indexed case-insensitively. Value is "" if the information isnt a pair.
return void

OnCtcpReply() protected method

Fires when the Client receives any kind of CTCP reply.
protected OnCtcpReply ( IrcUser user, IrcChannel chan, string reply, string args ) : void
user IrcUser The User who sent the text
chan IrcChannel
reply string The reply type (such as VERSION)
args string The text which was sent in addition to the reply
return void

OnCtcpRequest() protected method

Fires when the Client receives any kind of CTCP request. Automatically replies to the VERSION request with the content of the Version variable if not overridden.
protected OnCtcpRequest ( IrcUser user, IrcChannel chan, string request, string args ) : void
user IrcUser The User who sent the text
chan IrcChannel The Channel where it was sent (can be null)
request string The request type (such as VERSION)
args string The text which was sent in addition to the request
return void

OnDisconnected() protected method

Fires when the Client disconnected.
protected OnDisconnected ( bool conLost ) : void
conLost bool
return void

OnError() protected method

Fires when an Error reply has been sent by the network (raw is greater than 399).
protected OnError ( IrcPacket packet ) : void
packet Squishy.Irc.Protocol.IrcPacket
return void

OnExceptionRaised() protected method

Fires when an exception is raised during the protocol handling.
protected OnExceptionRaised ( Exception e ) : void
e System.Exception The Exception thrown during the handling.
return void

OnFlagAdded() protected method

Fires when a User adds a Channel flag to another User.
protected OnFlagAdded ( IrcUser user, IrcChannel chan, Privilege priv, IrcUser target ) : void
user IrcUser
chan IrcChannel
priv Privilege
target IrcUser
return void

OnFlagDeleted() protected method

Fires when a User deletes a Channel flag from another User.
protected OnFlagDeleted ( IrcUser user, IrcChannel chan, Privilege priv, IrcUser target ) : void
user IrcUser
chan IrcChannel
priv Privilege
target IrcUser
return void

OnInvalidNick() protected method

Fires when a chosen nick is already in use.
protected OnInvalidNick ( string err, string nick, string args ) : void
err string
nick string
args string
return void

OnInvite() protected method

Fires when the specified User sends an invitation for the specified Channel.
protected OnInvite ( IrcUser user, string chan ) : void
user IrcUser
chan string
return void

OnJoin() protected method

Fires when the specified User joins the specified Channel.
protected OnJoin ( IrcUser user, IrcChannel chan ) : void
user IrcUser
chan IrcChannel
return void

OnKick() protected method

Fires when a User is kicked from a Channel.
protected OnKick ( IrcUser from, IrcChannel chan, IrcUser target, string reason ) : void
from IrcUser
chan IrcChannel
target IrcUser
reason string
return void

OnModeAdded() protected method

Fires when a User adds a Channel mode.
protected OnModeAdded ( IrcUser user, IrcChannel chan, string mode, string param ) : void
user IrcUser The User who has added the mode
chan IrcChannel
mode string The mode which has been changed
param string "" if the mode does not have any parameter
return void

OnModeDeleted() protected method

Fures when a User deletes a Channel mode.
protected OnModeDeleted ( IrcUser user, IrcChannel chan, string mode, string param ) : void
user IrcUser The User who has added the mode
chan IrcChannel
mode string The mode which has been changed
param string "" if the mode does not have any parameter
return void

OnNick() protected method

Fires when a User has changed the nick.
protected OnNick ( IrcUser user, string oldNick, string newNick ) : void
user IrcUser
oldNick string
newNick string
return void

OnNotice() protected method

Fires when the Client receives any kind of NOTICE.
protected OnNotice ( IrcUser user, IrcChannel chan, Squishy.Network.StringStream text ) : void
user IrcUser The User who sent the text
chan IrcChannel The Channel where it was sent (is null if its a private notice)
text Squishy.Network.StringStream The text which was sent
return void

OnPart() protected method

Fires when a User parts from a Channel.
protected OnPart ( IrcUser user, IrcChannel chan, string reason ) : void
user IrcUser
chan IrcChannel
reason string
return void

OnQueryMsg() protected method

Fires when the Client receives a PRIVMSG, directed to this Client itself.
protected OnQueryMsg ( IrcUser user, Squishy.Network.StringStream text ) : void
user IrcUser
text Squishy.Network.StringStream
return void

OnQuit() protected method

Fires when a User quits.
protected OnQuit ( IrcUser user, string reason ) : void
user IrcUser
reason string
return void

OnText() protected method

Fires when the Client receives any kind of PRIVMSG or NOTICE.
protected OnText ( IrcUser user, IrcChannel chan, Squishy.Network.StringStream text ) : void
user IrcUser The User who sent the text
chan IrcChannel
text Squishy.Network.StringStream The text which was sent
return void

OnTopic() protected method

Fires when the Topic for a Channel has been sent. Either when joining a Channel or when modified by a User.
protected OnTopic ( IrcUser user, IrcChannel chan, string text, bool initial ) : void
user IrcUser
chan IrcChannel
text string
initial bool
return void

OnUnknownCommandUsed() protected method

Fires when the aliasing engine cannot find a command. Sends the command to the Server when not overridden.
protected OnUnknownCommandUsed ( CmdTrigger trigger ) : void
trigger Squishy.Irc.Commands.CmdTrigger
return void

OnUnspecifiedInfo() protected method

Fires when an information is sent that is not captured by the intern protocol handler.
protected OnUnspecifiedInfo ( IrcPacket packet ) : void
packet Squishy.Irc.Protocol.IrcPacket
return void

OnUserDisappeared() protected method

Called whenever a User quits or parts all common Channels
protected OnUserDisappeared ( IrcUser user ) : void
user IrcUser
return void

OnUserEncountered() protected method

protected OnUserEncountered ( IrcUser user ) : void
user IrcUser
return void

OnUserLeftChannel() protected method

Fires when a user is kicked from or parts from a channel or quits.
protected OnUserLeftChannel ( IrcChannel chan, IrcUser user, string reason ) : void
chan IrcChannel
user IrcUser
reason string
return void

OnUserModeChanged() protected method

Fires when own Usermodes have been changed.
protected OnUserModeChanged ( ) : void
return void

OnUsersAdded() protected method

Fires when the Client receives the Names list for the specified Channel.
protected OnUsersAdded ( IrcChannel chan, IrcUser users ) : void
chan IrcChannel
users IrcUser An Array of Users who are on the Channel
return void

OnWhoReply() protected method

Fires when the Client receives a Who-reply (raw 352).
protected OnWhoReply ( string channame, string username, string host, string server, string nick, string flags, string hops, string info ) : void
channame string The name of the channel which the Who-reply was for or the User did something on last
username string The username of the User
host string The hostmask of the User
server string The server which the User is connected to
nick string The nick of the User
flags string The network flags of the User
hops string The hops of the User
info string Additional Info about the User
return void

Perform() protected method

Fires when the Client is fully logged on the network and the End of Motd is sent (raw 376).
protected Perform ( ) : void
return void

Send() public method

Uses the Client.Send(string) to enqueue the corresponding text into the ThrottledSendQueue.
public Send ( string text ) : void
text string
return void

SendNow() public method

Uses the Client.SendNow(text) to send a line of text immediately to the server.
public SendNow ( string text ) : void
text string
return void

SupportsSymbols() public method

Indicates wether or not the current Irc 4rk supports the specified Channel symbols (such as @,+ etc) - Independent on the sequence.
public SupportsSymbols ( string symbols ) : bool
symbols string A sequence of symbols, representing Channel flags (such as '@')
return bool

TriggersCommand() public method

public TriggersCommand ( IrcUser user, IrcChannel chan, Squishy.Network.StringStream input ) : bool
user IrcUser
chan IrcChannel
input Squishy.Network.StringStream
return bool

Property Details

Info public_oe property

public string Info
return string

Network public_oe property

Contains information and tools to operate on this specific Network.
public IrcNetworkInfo,Squishy.Irc Network
return IrcNetworkInfo

Privileges public_oe static_oe property

public static Privilege[] Privileges
return Privilege[]

ServerPassword public_oe property

public string ServerPassword
return string

WhiteSpace public_oe static_oe property

public static Regex,System.Text.RegularExpressions WhiteSpace
return System.Text.RegularExpressions.Regex

m_CommandHandler protected_oe property

protected IrcCommandHandler,Squishy.Irc.Commands m_CommandHandler
return Squishy.Irc.Commands.IrcCommandHandler

m_MaxNickLen protected_oe property

protected int m_MaxNickLen
return int

protHandler protected_oe property

protected IrcProtocolHandler,Squishy.Irc.Protocol protHandler
return Squishy.Irc.Protocol.IrcProtocolHandler