-
Notifications
You must be signed in to change notification settings - Fork 1
Connection Class
Stores all the information for making a connection to or disconnecting from an IRC server.
connection.Connection(srv)
Accepts one parameter:
- srv : a [Server Object](Server Class)
connection.Connection.host
The host name or IP address of the IRC server to connect to. str
connection.Connection.port
The numeric port of the server to connect to. int
connection.Connection.ssl
Whether to use SSL with the connection or not. bool
connection.Connection.sslVerify
Whether or the bot should verify SSL certificates. bool
connection.Connection.retries
How many times Snowboard should try to connect to a particular server. int
connection.Connection.delay
How much time, in seconds, that the server should wait between connection attempts. int
server.Server.__socket
A Socket Object to act on for establishing or removing a socket connection over TCP/IP. This is private so that external code cannot directly access the socket.
server.Server.__ssl
An SSL Object to act on for establishing or removing an SSL connection over an existing Socket Object. The SSL object takes a Socket and acts as an SSL wrapper for that Socket. This is private so that external code cannot directly access the socket.
server.Server.__connected
A bool that says if the server is actually connected or not. This is private so that external code cannot mistakenly say the connection is no longer active when it really is (or vise versa).
server.Server.connected()
Returns a bool of whether the connection is established or not.
server.Server.connect()
Establishes a connection to a server. Returns a bool of if the connection succeeded or not.
If the system is unable to connect due to a network issue (such as a DNS error, connection refusal, or a connection timeout) it disconnects.
server.Server.disconnect()
Disconnects from a server, destroying the .__ssl and .__socket objects and setting them to None.
server.Server.read()
Reads data from the server. If there is no data to read, it returns None. When there is data to read it reads a single character at a time out of the socket's buffer until it receives a LF character (\n), if there is a trailing CR character (\r) it strips it out. Messages from the server remove the ':' character from the front, if a full line of data has no characters left after removing the CRLF (\r\n) and the preceding ':' is empty - it returns None as if there was no data.
If the system encounters a connection error it sends an error message back to the console and disconnects.
server.Server.write(data)
Accepts one parameter:
- data : Data to be sent to the server. str
Sends data to the server. Sends data in chunks until the the data buffer has been sent. If the data cannot be sent, or no data can be sent, the system will disconnect.
If the system encounters a connection error it sends an error message back to the console and disconnects.