Navigation

 + + + 

SleepyBot - Functions

Almost all functions of PircBot are available in SleepyBot. You may use the PircBot API Docs instead of this table.

NOTE: Since there is already a function named "connect" in Sleep, the function to connect to a server in SleepyBot is called "connectServer".

Functions Descriptions
SleepyBot 1.1 API
connectServer($server[,$port[,$passwd]])Connects the server (void)
reconnectServer()Reconnects the server (void)
disconnectServer()Disconnects the server (void)
quitServer([$quitmsg])Disconnects the server (void) (unsynchronized method)
startIdentServer()Starts the ident-server
identify($password)Identify the bot with NickServ, supplying the appropriate password. Some IRC Networks (such as freenode) require users to register and identify with NickServ before they are able to send private messages to other users, thus reducing the amount of spam. This method issues a raw NICKSERV command to the server, and is therefore safer than the alternative approach of sending a private message to NickServ. However, if your IRC network is only compatible with the private message approach, you may typically identify like so: sendMessage("NickServ", "identify PASSWORD");
joinChannel($channel)Lets the bot join $channel
partChannel([$reason])Leave current channel[, providing a reason]
sendRawLine($line)Sends a raw line
sendRawLineViaQueue()Sends a raw line via the message queue
sendMessage($target,$message)Sends a message to a channel or a nick
sendAction($target,$action)Sends an action to a channel or a nick
sendNotice($target,$notice)Sends a notice to a channel or a nick
sendCTCPCommand($target,$command)Sends a CTCP command to a channel or user.
changeNick($newNick)Attempt to change the current nick (nickname) of the bot when it is connected to an IRC server. After confirmation of a successful nick change, the getNick method will return the new nick.
setMode($channel,$mode)Set the mode of a channel. This may require the bot to have operator status on the channel
ban($channel, $hostmask)Bans a user from a channel.
unBan($channel, $hostmask)Unbans a user from a channel.
kick($channel, $nick [, $reason])Kicks a user from a channel. This may require the bot to have operator status in the channel.
op($channel, $nick)Grants operator privilidges to a user on a channel. Successful use of this method may require the bot to have operator status itself.
deOp($channel, $nick)Removes operator privilidges from a user on a channel. Successful use of this method may require the bot to have operator status itself.
voice($channel, $nick)Grants voice privilidges to a user on a channel. Successful use of this method may require the bot to have operator status itself.>Grants voice privilidges to a user on a channel. Successful use of this method may require the bot to have operator status itself.
deVoice($channel, $nick)Removes voice privilidges from a user on a channel. Successful use of this method may require the bot to have operator status itself.
setTopic($channel, $topic)Set the topic for a channel. This method attempts to set the topic of a channel. This may require the bot to have operator status if the topic is protected.
setName($name)Sets the name of the bot, which will be used as its nick when it tries to join an IRC server. This should be set before joining any servers, otherwise the default nick will be used. You would typically call this method from the init function.
$ getName()Gets the name of the bot.
setLogin($login)Sets the internal login of the bot. This should be set before joining any servers.
$ getLogin()Gets the internal login of the Bot.
setVersion($version)Sets the internal version of the bot. This should be set before joining any servers.
$ getVersion()Gets the internal version of the PircBot.
setFinger($finger)Sets the interal finger message. This should be set before joining any servers.
$ getFinger()Gets the internal finger message of the bot.
$ isConnected()Returns whether or not the PircBot is currently connected to a server. The result of this method should only act as a rough guide, as the result may not be valid by the time you act upon it.
setMessageDelay($longvalue)Sets the number of milliseconds to delay between consecutive messages when there are multiple messages waiting in the outgoing message queue. This has a default value of 1000ms. Changing is not recommended.
$ getMessageDelay()Returns the number of milliseconds that will be used to separate consecutive messages to the server from the outgoing message queue.
$ getMaxLineLength()The maximum line length (currently fixed at 512). All lines greater than this length will be truncated before being sent to the IRC server.
$ getOutgoingQueueSize()Gets the number of lines currently waiting in the outgoing message Queue. If this returns 0, then the Queue is empty and any new message is likely to be sent to the IRC server immediately.
$ getServer()Returns the name of the last IRC server the PircBot tried to connect to. This does not imply that the connection attempt to the server was successful (we suggest you look at the onConnect method). A value of null is returned if the PircBot has never tried to connect to a server.
$ getPort()Returns the port number of the last IRC server that the PircBot tried to connect to. This does not imply that the connection attempt to the server was successful (we suggest you look at the onConnect method). A value of -1 is returned if the PircBot has never tried to connect to a server.
$ getPassword()Returns the last password that we used when connecting to an IRC server. This does not imply that the connection attempt to the server was successful (we suggest you look at the onConnect method). A value of null is returned if the PircBot has never tried to connect to a server using a password.
$ getNick()Returns the current nick of the bot. Note that if you have just changed your nick, this method will still return the old nick until confirmation of the nick change is received from the server.
listChannels([$parameters])Issues a request for a list of all channels on the IRC server. When the bot receives information for each channel, it will call the onChannelInfo method, which you will need to override if you want it to do anything useful.
setVerbose($verbose)Sets the verbose mode. If verbose mode is set to true, then log entries will be printed to the standard output. The default value is false and will result in no output.
setEncoding($encoding)Sets the encoding charset to be used when sending or receiving lines from the IRC server. If set to null, then the platform's default charset is used. You should only use this method if you are trying to send text to an IRC server in a different charset, e.g. "GB2312" for Chinese encoding. If a PircBot is currently connected to a server, then it must reconnect before this change takes effect.
$ getEncoding()Returns the encoding used to send and receive lines from the IRC server, or null if not set.
@ getChannels()Returns an array of all channels that we are in. Note that if you call this method immediately after joining a new channel, the new channel may not appear in this array as it is not possible to tell if the join was successful until a response is received from the IRC server.
$ getInetAddress()Returns the InetAddress used by the bot or null if never connected.
$ getDccInetAddress()Returns the InetAddress used when sending DCC chat or file transfers. If this is null, the default InetAddress will be used.
setDccInetAddress($inetaddress)Sets the InetAddress to be used when sending DCC chat or file transfers. This can be very useful when you are running a bot on a machine which is behind a firewall and you need to tell receiving clients to connect to a NAT/router, which then forwards the connection.($null to use the default.)
$ ipToLong($ip_as_byte_array)Returns a long representation of the IP address represented by a byte[] of size 4 and returns this as a long representation of the same IP address.
@ longToIp($ip_as_long)Returns an integer array of size 4 representing the same IP address represented as a long
logAppend($message)Logs the $message if verbose mode is set to true to the standard output. You could provide your own logAppend function in the bot-script
dccSendChatRequest($nick [, $timeout])Sends a chat request to $nick (waiting $timeout millis for the recipient to accept the chat connection (default 120000, as recommended by PircBot authors). This is function returns nothing, which is different as in PircBot, but it follows the recommendation to call this method within a new Thread. If the request has been accepted the DccChat object is passed to onChatRequestAccepted.
onChatRequestAccepted($chat)Called when a chat request has been accepted. See dccSendChatRequest.
chatReadLine( $chat )Waits for the next line and then calls onChatReadline
onChatReadline(DccChat chat, String line)Called when a new line of text has been arived.
$ isDccFileTransfer($chat)Returns 1 if $chat represents an org.jibble.DccChat object else $null.
chatAccept( $chat )Accepts a dcc chat request which was send to this bot.
chatSendLine($chat, String line)Sends a line of text to the client at the other end of the DCC Chat connection. $line should not include linefeed characters.
chatClose($chat)Closes the DccChat
$ chatGetNick($chat)Returns the nickname of the other user taking part.
$ chatGetLogin($chat)Returns the login of the other user taking part or null if we sent it.
$ chatGetHostname($chat)Returns the hostname or null if we sent it.
chatGetBufferedReaderNOT IMPLEMENTED!
chatGetBufferedWriterNOT IMPLEMENTED!
$ dccSendFile(File file, String nick, int timeout)
$ isDccFileTransfer($dft)Returns 1 if $dft represents a org.jibble.DccFileTransfer object else $null.
dftReceive($dft, $file[, $resume])Receives a DccFileTransfer and writes it to the specified file. Resuming allows a partial download to be continue from the end of the current file contents.
$ dftGetNick($dft)Returns the nick of the other user taking part in the file transfer represented by $dft.
$ dftGetLogin($dft)Returns the login of the file sender or null if we are sending.
$ dftGetHostname($dft)Returns the hostname of the file sender or null if we are sending.
$ dftGetFile($dft)Returns the suggested file to be used for the transfer.
$ dftGetPort($dft)Returns the port number to be used when making the connection.
$ dftIsIncoming($dft)Returns 1 if the file transfer is incoming (somebody is sending the file to us).
$ dftIsOutgoing($dft)Returns 1 if the file transfer is outgoing (we are sending the file to someone).
dftSetPacketDelay($dft, $millis)Sets the delay time between sending or receiving each packet. Default is 0. This is useful for throttling the speed of file transfers to maintain a good quality of service for other things on the machine or network.
$ dftGetPacketDelay($dft)Returns the delay time between each packet that is send or received.
$ dftGetSize($dft)Returns the size (in bytes) of the file being transfered or -1 if the sender did not specify this value.
$ dftGetProgress($dft)Returns the progress (in bytes) of the current file transfer. When resuming, this represents the total number of bytes in the file, which may be greater than the amount of bytes resumed in just this transfer.
$ dftGetProgressPercentage($dft)Returns the progress of the file transfer as a percentage. Note that this should never be negative, but could become greater than 100% if you attempt to resume a larger file onto a partially downloaded file that was smaller.
$ dftGetTransferRate($dft)Returns the rate of data transfer in bytes per second. This value is an estimate based on the number of bytes transfered since the connection was established.
dftClose($dft)Stops the DCC file transfer by closing the connection.
@ getUsersReturn an array containing the User objects
$ isUser($user)Returns 1 if $user represents an org.jibble.User object else $null
$ userIsOp($user)Returns 1 if $user represents an User object and whether or not the user represented by this object is an operator. If the User object has been obtained from a list of users in a channel, then this will reflect the user's operator status in that channel.
$ userHasVoice($user)Returns 1 if $user represents an User object and whether or not the user represented by this object has voice. If the User object has been obtained from a list of users in a channel, then this will reflect the user's voice status in that channel.
$ userGetNick($user)Returns the nick of the user.
$ userGetPrefix($user)Returns the prefix of the user. If the User object has been obtained from a list of users in a channel, then this will reflect the user's status in that channel. If there is no prefix, then an empty String is returned.
$ userToString($user)Returns the nick of the user complete with their prefix if they have one, e.g. "@Dave".
$ userCompareTo($user)Returns the result of calling the compareTo method on lowercased nicks. This is useful for sorting lists of User objects.
$ userEqualsUser($user, $other_user)Returns 1 if the nick represented by the User object is the same as the nick of the User object given as $other_user. A case insensitive comparison is made.
$ userEqualsNick($user, $nick)Returns true if the nick represented by the User object is the same as the argument. A case insensitive comparison is made.
$ userHashCode($user)Returns the hash code of the User object.
$ newJavaFile($filename)Returns java.io.File(String filename) encapsulated in a sleep-scalar
$ newJavaFile($parentname, $filename)Returns java.io.File(String parent, String child) encapsulated in a sleep-scalar
$ newJavaFile($parentfile, $filename)Returns java.io.File(File parent, String child) encapsulated in a sleep-scalar
$ isJavaFile($file)Return 1 if $file represents a java.io.File
$ javaFileExists($file)Return 1 if $file represents a java.io.File and this file exists
$ javaFileLength($file)Returns the length of the file
$ javaFileGetName($file)Returns the name of the file
$ javaFileIsDir($file)Returns 1 if $file represents a java.io.File and this file exists and is a directory
$ javaFileIsFile($file)Returns 1 if $file represents a java.io.File and this file exists and is a normal file
$ javaFileCanRead($file)Returns 1 if $file represents a java.io.File and this file exists and can be read.
$ javaFileCanWrite($file)Returns 1 if $file represents a java.io.File and the file system actually contains a file the application is allowed to write to the file.
$ javaFileIsHidden($file)Returns 1 if $file represents a java.io.File and this file is hidden according to the conventions of the underlying platform.
$ javaFileIsAbsolute($file)Returns 1 if $file represents a java.io.File and the path name is absolute.
$ javaFileLastModified($file)Returns the time that the file was last modified.
$ javaFileGetPath($file)Returns the path of $file as string.
$ javaFileGetParent($file)Returns the path of the parent of $file as string.
$ javaFileGetAbsolutePath($file)Returns the absolute path of $file as string.
$ javaFileGetCanonicalPath($file)Returns the canonical pathname string of $file.
$ javaFileGetParentFile($file)Returns the parent of $file as file.
$ javaFileGetAbsoluteFile($file)Returns the absolute form of $file as file.
$ javaFileGetCanonicalFile($file)Returns the canonical form of $file as file.
@ javaFileList($file [, $filter])Returns a sleep-array optional filtered by a filter as returned by newFileFilter.
@ javaFileListFiles($file [, $filter])Returns a sleep-array optional filtered by a filter as returned by newFileFilter.
@ javaFileListRoots($file)Returns a sleep-array of files representing the filesystem roots
$ javaFileRenameTo($file, $newname)Returns 1 if and only if the renaming succeeded.
$ javaFileSetLastModified($file,$time)Returns 1 if and only if the operation succeeded.($time is a long)
$ javaFileSetReadOnly($file)Returns 1 if and only if the operation succeeded.
$ javaFileMakeDir(NOT IMPLEMETED)
$ javaFileMakeDirs(NOT IMPLEMETED)
$ newFileFilter($closure [, $description])Returns a FileFilter/FilenameFilter for use in javaFileList or javaFileListFiles
$ isFileFilter($filter)Return 1 if and only if $filter represents a FileFilter/FilenameFilter as returned by newFileFilter
inetAddressByName($hostname)Returns a java.net.InetAddress or $null if a UnknownHostException is thrown. (See java.net.InetAddress.getByName(String hostname))
inetAddressByAddress($)Returns a java.net.InetAddress or $null if a UnknownHostException is thrown. (See java.net.InetAddress.getByName(String hostname))
$ isInetAddress($inetaddress)Returns 1 if $inetaddress represents a java.net.InetAddress.
$ inetAddressGetAddress($inetaddress)Returns a byte[] (the raw IP address).
% properties( ... )same as hash sleep-function but "cleans" the key. (The hash function does not handle the key correct if the key => value syntax is used and the key contains a dot (bot.name => 'CoolBot') to create the key/value pairs, the key would be 'bot . name', using "bot.name=CoolBot" does not have this effect)
% loadProperties($filename)Loads java.util.Properties from a file and returns it as a sleep hash.
storeProperties(%properties, $filename [, description])Stores the hash as a java.util.Properties file.
$ asProperties(%hash)Returns a sleep hash as java.util.Properties
$ isTimer($timer)Returns 1 if $timer is a Timer object as returned by addTimer (see below)
$ addTimer($closure, $delay, $repeats [, $param1, ...])Returns a timer (actually a java.util.TimerTask implementation). Note that the first parameter($1) to the closure is the timer object, the passed parameters start at $2. This allows it to stop the timer in the closure when a condition is reached, you need not to store the reference this function returns. Set $repeats to 0 for repeating until last judgement.
stopTimer($timer)Stops the $timer. Since the timer is passed as first parameter to the closure you may call this function inside that closure: { ... if ( $condition ) { stopTimer($1); } ... }
$ isByteArray($byte_array)Returns 1 if and only if $byte_array is a java byte[].
$ toByteArray(@sleeparray)Returns a sleep-array (of integers) as a java byte[]. (Conversion is done by: new Integer(<int_from_sleep_array>).byteValue()).
@ fromByteArray($byte_array)Returns a java byte[] as a sleep-array (of integers). (Conversion is done by: new Byte(bytes[i]).intValue()).
$ removeColors($string)Removes colors from $string, returns the cleaned string
$ removeFormatting($string)Removes formatings from $string, returns the cleaned string
$ removeFormattingAndColors($string)Removes colors and formattings from $string, returns the cleaned string
$ startsWith($string, $start)Returns 1 (true) if $string starts with $start else $null (false)
$ startsWithIgnoreCase($string, $start)Returns 1 (true) if lowercase $string starts with lowercase $start else $null (false)
$ endsWith($string, $end)Returns 1 (true) if $string ends with $end else $null (false)
$ endsWithIgnoreCase($string, $end)Returns 1 (true) if lowercase $string ends with lowercase $end else $null (false)

ululatus.org     Valid XHTML 1.0!      Valid CSS!      Last modified 16 Oct 2008 13:03