Debian Codegraph @

help/alias/functions

raw
1 ! $Id: functions,v 1.11 2007-11-08 16:02:34 f Exp $
2 !
3 ! Copyright (c) 1990-2001 Michael Sandrof, Troy Rollo, Matthew Green,
4 ! and other ircII contributors.
5 !
6 ! All rights reserved. See the HELP SCROLLZ COPYRIGHT file for more
7 ! information.
8 !
9 ScrollZ Functions
10 ScrollZ functions are substituted with the format $FUNCTION(arguments).
11 A function is an ALIAS which assigns a value to FUNCTION_RETURN.
12 For example:
13 ALIAS DOUBLE assign FUNCTION_RETURN ${[$0]+[$0]}
14 which is the same as:
15 ALIAS DOUBLE @ function_return = [$0] * 2
16 used with:
17 ALIAS SHOWDOUBLE echo $DOUBLE($0)
18 will cause
19 SHOWDOUBLE 7
20 to display "14".
21
22 The following built-in functions already exist and cannot be overriden:
23 (n!u@h stands for nick!user@host)
24
25 CDCCSLOTS() Returns the number of free Cdcc slots
26 CDCCQSLOTS() Returns the number of free Cdcc queue slots
27 CHATPEERS() Returns the list of nicks who you have dcc-chat
28 connections with, in format nick,nick2,...
29 Useful if you want to broadcast.
30 CHANUSERS(channel X) Returns a list of users on channel.
31 If X is 1 every nick returned will have a status
32 character prepended to it:
33 @ - chanop
34 + - voiced
35 % - halfopped
36 . - other
37 CHECKUSER(n!u@h channel) Returns user flags, filter and channels
38 for userlist entry matching n!u@h and channel
39 or -1 on error
40 CHECKSHIT(n!u@h channel) Returns user flags, filter and channels
41 for shitlist entry matching n!u@h and channel
42 or -1 on error
43 CHR(LIST) Returns string from a list of ascii codes
44 CLOSE(HANDLE) Closes the file denoted by HANDLE.
45 COLOR(STRING) STRING can be two numbers in which case the first
46 number is the event and the second number is in
47 range from 1 to 6. In this case the color number
48 matching second number is returned from the colors
49 defined for the event matching first number. See
50 also COLOR.
51 Additionally you can specify color mnemonics:
52 normal, bold, underline, flash, reverse, black,
53 red, green, yellow, blue, purple, cyan, white,
54 blackbg, redbg, greenbg, yellowbg, bluebg,
55 purplebg, cyanbg, whitebg or nobold (this one
56 turns all bold off).
57 CONNECT(HOST PORT) Returns the file descriptor for the connection.
58 A NULL fd means host could not be resolved.
59 Negative fd means some error occurred in the attempt.
60 Communication through the connection is done with
61 DCC RAW and ON DCC_RAW.
62 (See DCC RAW and ON DCC_RAW)
63 COUNTRY(CODE) Returns the country name for CODE.
64 Example: $country(fi)
65 CURPOS() Returns the postition from the start of the input line
66 to where the cursor is now.
67 CRYPT(salt key) Crypts the input using the BSD crypt() function.
68 There is no way of decrypting the result. This
69 could be used for password crypting in a bot.
70 (Note that this function is available
71 only if the system libraries contain it.)
72 DCCLIST(nick) Returns a list of dcc operations for specified nick.
73 The list is a string which consists of two-character
74 constants, where first char is one of:
75 (C)hat, (S)end, (G)et, (T)alk, s(U)mmon,
76 raw_(L)isten and (R)aw.
77 Second char is one of:
78 (C)losed, (A)ctive, (W)aiting, (O)ffered.
79 You can use this for example to detect if
80 you have a dcc-chat connection to someone.
81 Returns 0 if you don't specify nick.
82 DECODE(encoded text) Decode a single STRING of text produced by ENCODE()
83 into it's original characters. Note that these are
84 case sensitive.
85 EOF(HANDLE) Returns non-zero if end-of-file indicator is set
86 for file denoted by HANDLE.
87 ENCODE(input text) Convert input text to an encoded string suitable for
88 use as an ScrollZ variable or alias name. Any special
89 including spaces can be encoded into the string.
90 FILESTAT(filename) Performs a stat(2) on the specified filename. The
91 returned values are size, uid, gid, mode and filename.
92 FSIZE(FILENAME) Returns the filesize for FILENAME. The FILENAME is
93 expanded before checking - you can use ~ in the
94 filename to denote your home dir.
95 HASVOICE(nick channel) Returns 1 if nick has voice on the given channel.
96 Note that if the person is an operator on the given
97 channel, this function is unreliable: It returns 1.
98 HHOST(u@h) Returns the host from user@host
99 IDLE() Returns the number of seconds since the last keyboard
100 activity.
101 IGNORED(NICK TYPE) Returns "ignored", "highlighted", "dont" or "0",
102 depending on what ignore action will be applied to
103 this NICK and TYPE of ignorance. TYPE must be one
104 of MSGS, PUBLIC, WALLS, WALLOPS, INVITES, NOTICES,
105 NOTES, CTCP, CRAP, PART, JOIN, NICK or QUIT.
106 INDEX(CHARLIST STRING) Returns the index to the first character in STRING
107 which appears in CHARLIST. If the first char in
108 CHARLIST is a '^' returns the index to first char in
109 STRING *NOT* in CHARLIST.
110 ISCHANNEL(word) Returns 1 if word is a valid channel name.
111 ISCHANOP(nick channel) Returns 1 if nick is a chanop on the given channel.
112 LEFT(COUNT STRING) Returns the COUNT leftmost bytes from the STRING.
113 LISTEN(PORT) Creates a listening socket on the specified port.
114 If the port # is not specified then it returns the
115 number of the port it chose arbitrarily. It cannot
116 open a port# < 1025
117 MATCH(PATTERN WORDS) Returns an index into the list of WORDS of the first
118 match for the given PATTERN. Returns 1 if it matches
119 the first word, 0 if it matches none.
120 MID(INDEX COUNT STRING) Returns COUNT bytes starting at position INDEX
121 in STRING.
122 MYCHANNELS(refnum) Returns a string with a list of channels on that
123 windows server. (defaults to current window)
124 MYSERVERS() Returns a string of the names of the servers
125 you are connected to.
126 NOTIFY(TYPE) Returns either the TYPE "here", "gone" or "all"
127 lists, default being "here".
128 ONCHANNEL(nick channel) Returns 1 if nick is on channel
129 OPEN(F r|w|a) Opens the file F and returns its handle. File
130 mode is one of:
131 r - read
132 w - write
133 a - append
134 PATTERN(PATTERN WORDS) Returns all words from a list that are matched
135 by a pattern
136 the first word, 0 if it matches none.
137 PID() Returns the current process ID.
138 PPID() Returns the current parent process iD.
139 QUERYNICK(refnum) Returns the nick, if any, that the window is queried
140 to.
141 RAND(LIMIT) Returns a random number x such that 0<=x<LIMIT
142 READ(HANDLE) Returns one line from file denoted by HANDLE.
143 REGEXP(PATTERN STRING) Returns 1 if STRING matches given PATTERN, 0 if there is
144 no match. POSIX.2 regular expressions are supported.
145 REGEXPREP(PATTERN STRING) Performs search & replace using POSIX.2 regular
146 expressions supporting up to 10 back references in $# style,
147 example:
148 REGEXPREP("/a (.*) c (.*)/$$1 $$2/" a b c d) would return
149 b d
150 RENAME(OLD NEW) Renames file OLD to NEW.
151 RIGHT(COUNT STRING) Returns the COUNT rightmost bytes from the STRING.
152 RINDEX(CHARLIST STRING) Returns the index to the last character in STRING
153 which appears in CHARLIST.
154 RMATCH(WORD PATTERNS) Returns an index into the list of PATTERNS of the
155 pattern which best matches the given WORD. Returns
156 1 for the first pattern, 0 for none.
157 SAR(C/S/R/D) Search and replace. C is a command:
158 r - treat D as variable name, return the replaced
159 data to the variable
160 g - replace all instances
161 S is search string, R is replace string.
162 Examples: $sar(/doe/beavis/john doe)
163 $sar(r/doe/beavis/foo)
164 SCREENS() Returns a list of the current screen.
165 SERVERTYPE() Returns server version ("IRC2.X", where X is a number,
166 or "IRC Unknown" if unrecognized)
167 SRAND(SEED) Seeds the random number generator and returns nothing.
168 The seed may be a long integer, although only the low
169 integer is used.
170 STIME(TIMEVAL) Returns the date and time in English that corresponds
171 to the long integer TIMEVAL.
172 STRFTIME(time format) Returns a string with the time formatted according
173 to the given format.
174 (Note that this function is available
175 only if the system libraries contain it.)
176 STRIP(CHARLIST STRING) Returns the STRING with all occurrences of characters
177 listed in CHARLIST removed.
178 STRIPANSI(STRING) Returns the STRING with all ANSI color sequences
179 removed from it
180 STRIPCRAP(STRING) Returns the STRING with all non-printable characters
181 removed from it
182 STRLEN(STRING) Returns the length of STRING
183 STRNUM(STRING) Returns the number of words in STRING
184 STRSTR(STR1 STR2) Returns the substring STR2 in STR1
185 Example: $STRSTR(/JOHN DOE/DOE)
186 SZVAR(VARNAME) Returns value of ScrollZ variable VARNAME
187 All ScrollZ variables which are not modifyable
188 through SET can be queried this way. The
189 VARNAME matches the command name, example:
190 $szvar(nhprot). For the Cdcc variables don't
191 put a space between Cdcc and command name,
192 example: $szvar(cdcclongstatus).
193 TDIFF(TIME_INTERVAL) Takes a TIME_INTERVAL in seconds and returns it in
194 the format.. dd days hh hours mm minutes ss seconds
195 Any fields with 00 are omitted.
196 TIME() Returns the current system time as a long integer
197 TOPIC(CHANNEL) Returns the topic for CHANNEL, time the topic was
198 set and who set the topic.
199 TOUPPER(string) Convert string to upper case.
200 TOLOWER(string) Convert string to lower case.
201 TR(/set1/set2/string) Returns translated string where character from set1 is
202 replaced with character on the same position in set2
203 UH(nickname) Returns nick!user@host for given nickname or -1
204 if the information is not available
205 UHOST(n!u@h) Returns the user@host from nick!user@host
206 URL(NUMBER [string]) Returns URL NUMBER from internally stored URLs
207 If string is not empty it also returns source of URL
208 USERHOST() Returns the user@host value under which the current
209 message was sent if you are on a 2.7 server or better.
210 WINDOWS() Returns a list of the current windows.
211 WINNUM() Returns the current window number. This is always
212 the window which is indicated by STATUS_WINDOW.
213 WINNAM() Returns the current window name.
214 This is always the window which is indicated by
215 STATUS_WINDOW. If the window has no name, it returns
216 nothing.
217 WINCOLS() Returns the number columns in this window, or -1 if
218 this can not be determined.
219 WINROWS() Returns the number rows in this window, or -1 if
220 this can not be determined.
221 WINVIS() Returns 1 if the window is currently visible.
222 WINSERVER() Returns the server associated with the window.
223 WINSERVERGROUP() Returns the server group associated with the window.
224 WORD(INDEX WORDS) Returns the single word in the list of WORDS pointed
225 to by INDEX.
226 WRITE(HANDLE TEXT) Writes TEXT to file denoted by HANDLE.
227 SHELLFIX(input text) Convert input text so that it can safely be passed
228 to a command line program without unexpected side
229 effects commonly used to hack the user's shell.
230 URLENCODE(input text) Convert input text so that it can be used as part of
231 an url, for example as a query parameter when executing
232 lynx. Note that you may have to SHELLFIX() also.
233
234 Note:
235 The argument separator for functions is the space character, not the comma.
236
237 See Also:
238 ALIAS SZVAR