! $Id: functions,v 1.9 2005/08/08 18:49:50 f Exp $ ! ! Copyright (c) 1990-2001 Michael Sandrof, Troy Rollo, Matthew Green, ! and other ircII contributors. ! ! All rights reserved. See the HELP SCROLLZ COPYRIGHT file for more ! information. ! ScrollZ Functions ScrollZ functions are substituted with the format $FUNCTION(arguments). A function is an ALIAS which assigns a value to FUNCTION_RETURN. For example: ALIAS DOUBLE assign FUNCTION_RETURN ${[$0]+[$0]} which is the same as: ALIAS DOUBLE @ function_return = [$0] * 2 used with: ALIAS SHOWDOUBLE echo $DOUBLE($0) will cause SHOWDOUBLE 7 to display "14". The following built-in functions already exist and cannot be overriden: (n!u@h stands for nick!user@host) CDCCSLOTS() Returns the number of free Cdcc slots CDCCQSLOTS() Returns the number of free Cdcc queue slots CHATPEERS() Returns the list of nicks who you have dcc-chat connections with, in format nick,nick2,... Useful if you want to broadcast. CHANUSERS(channel X) Returns a list of users on channel. If X is 1 every nick returned will have a status character prepended to it: @ - chanop + - voiced % - halfopped . - other CHECKUSER(n!u@h channel) Returns user flags, filter and channels for userlist entry matching n!u@h and channel or -1 on error CHECKSHIT(n!u@h channel) Returns user flags, filter and channels for shitlist entry matching n!u@h and channel or -1 on error CLOSE(HANDLE) Closes the file denoted by HANDLE. COLOR(STRING) STRING can be two numbers in which case the first number is the event and the second number is in range from 1 to 6. In this case the color number matching second number is returned from the colors defined for the event matching first number. See also COLOR. Additionally you can specify color mnemonics: normal, bold, underline, flash, reverse, black, red, green, yellow, blue, purple, cyan, white, blackbg, redbg, greenbg, yellowbg, bluebg, purplebg, cyanbg, whitebg or nobold (this one turns all bold off). CONNECT(HOST PORT) Returns the file descriptor for the connection. A NULL fd means host could not be resolved. Negative fd means some error occurred in the attempt. Communication through the connection is done with DCC RAW and ON DCC_RAW. (See DCC RAW and ON DCC_RAW) COUNTRY(CODE) Returns the country name for CODE. Example: $country(fi) CURPOS() Returns the postition from the start of the input line to where the cursor is now. CRYPT(salt key) Crypts the input using the BSD crypt() function. There is no way of decrypting the result. This could be used for password crypting in a bot. (Note that this function is available only if the system libraries contain it.) DCCLIST(nick) Returns a list of dcc operations for specified nick. The list is a string which consists of two-character constants, where first char is one of: (C)hat, (S)end, (G)et, (T)alk, s(U)mmon, raw_(L)isten and (R)aw. Second char is one of: (C)losed, (A)ctive, (W)aiting, (O)ffered. You can use this for example to detect if you have a dcc-chat connection to someone. Returns 0 if you don't specify nick. DECODE(encoded text) Decode a single STRING of text produced by ENCODE() into it's original characters. Note that these are case sensitive. EOF(HANDLE) Returns non-zero if end-of-file indicator is set for file denoted by HANDLE. ENCODE(input text) Convert input text to an encoded string suitable for use as an ScrollZ variable or alias name. Any special including spaces can be encoded into the string. FILESTAT(filename) Performs a stat(2) on the specified filename. The returned values are size, uid, gid, mode and filename. FSIZE(FILENAME) Returns the filesize for FILENAME. The FILENAME is expanded before checking - you can use ~ in the filename to denote your home dir. HASVOICE(nick channel) Returns 1 if nick has voice on the given channel. Note that if the person is an operator on the given channel, this function is unreliable: It returns 1. HHOST(u@h) Returns the host from user@host IDLE() Returns the number of seconds since the last keyboard activity. IGNORED(NICK TYPE) Returns "ignored", "highlighted", "dont" or "0", depending on what ignore action will be applied to this NICK and TYPE of ignorance. TYPE must be one of MSGS, PUBLIC, WALLS, WALLOPS, INVITES, NOTICES, NOTES, CTCP or CRAP. INDEX(CHARLIST STRING) Returns the index to the first character in STRING which appears in CHARLIST. If the first char in CHARLIST is a '^' returns the index to first char in STRING *NOT* in CHARLIST. ISCHANNEL(word) Returns 1 if word is a valid channel name. ISCHANOP(nick channel) Returns 1 if nick is a chanop on the given channel. LEFT(COUNT STRING) Returns the COUNT leftmost bytes from the STRING. LISTEN(PORT) Creates a listening socket on the specified port. If the port # is not specified then it returns the number of the port it chose arbitrarily. It cannot open a port# < 1025 MATCH(PATTERN WORDS) Returns an index into the list of WORDS of the first match for the given PATTERN. Returns 1 if it matches the first word, 0 if it matches none. MID(INDEX COUNT STRING) Returns COUNT bytes starting at position INDEX in STRING. MYCHANNELS(refnum) Returns a string with a list of channels on that windows server. (defaults to current window) MYSERVERS() Returns a string of the names of the servers you are connected to. NOTIFY(TYPE) Returns either the TYPE "here", "gone" or "all" lists, default being "here". ONCHANNEL(nick channel) Returns 1 if nick is on channel OPEN(F r|w|a) Opens the file F and returns its handle. File mode is one of: r - read w - write a - append PID() Returns the current process ID. PPID() Returns the current parent process iD. QUERYNICK(refnum) Returns the nick, if any, that the window is queried to. RAND(LIMIT) Returns a random number x such that 0<=x