forked from g2x3k/php-irc
-
Notifications
You must be signed in to change notification settings - Fork 2
/
command_reference.txt
executable file
·870 lines (585 loc) · 26.2 KB
/
command_reference.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
+---------------------------------------------------------------------------
| PHP-IRC v2.2.1 Service Release
| ========================================================
| by Manick
| (c) 2001-2006 by http://www.phpbots.org/
| Contact: [email protected]
| irc: #[email protected]
| ========================================================
+---------------------------------------------------------------------------
| > Module Command Reference
+---------------------------------------------------------------------------
| > This program is free software; you can redistribute it and/or
| > modify it under the terms of the GNU General Public License
| > as published by the Free Software Foundation; either version 2
| > of the License, or (at your option) any later version.
| >
| > This program is distributed in the hope that it will be useful,
| > but WITHOUT ANY WARRANTY; without even the implied warranty of
| > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| > GNU General Public License for more details.
| >
| > You should have received a copy of the GNU General Public License
| > along with this program; if not, write to the Free Software
| > Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+---------------------------------------------------------------------------
| Changes
| =======-------
| > If you wish to suggest or submit an update/change to the source
| > code, email me at [email protected] with the change, and I
| > will look to adding it in as soon as I can.
+---------------------------------------------------------------------------
The following file is a quickly put together command reference of all the functions that you can use to complement the php scripting language while writing your modules.
===============
Quick Reference (See below the quick reference for function descriptions)
===============
irc.php (Accessed with $this->ircClass->)
-----------------------------------------
array parseModes($modeString)
array getMaintainedChannels()
string getClientConf($var = "")
string getNick()
string getServerConf($var)
string getStatusString($status)
string getClientIP($long = 1)
class getChannelData($channel)
class getUserData($user, $channel = "")
void disconnect()
void setClientConfigVar($var, $value)
void joinChannel($chan)
void sendRaw($text, $force = false)
void privMsg($who, $msg, $queue = 1)
void action($who, $msg, $queue = 1)
void notice($who, $msg, $queue = 1)
void log($text)
void maintainChannel($channel, $key = "")
void removeMaintain($channel)
void addQuery($host, $port, $query, $line, $class, $function)
int getStatusRaw()
bool changeMode($chan, $act, $mode, $user)
bool isOnline($nick, $chan)
bool isMode($nick, $channel, $mode)
bool isChanMode($channel, $mode, $extra = "")
bool hasModeSet($chan, $user, $modes);
bool hostMasksMatch($mask1, $mask2)
bool checkIgnore($mask)
socket.php (Accessed with $this->socketClass->)
-----------------------------------------------
string getHost($sockInt)
string getQueue($sockInt)
string getQueueLine($sockInt)
int sendSocket($sockInt, $data)
int getSockStatus($sockInt)
object getSockData($sockInt)
bool hasWriteQueue($sockInt)
bool hasLine($sockInt)
timers.php (Accessed with $this->timerClass->)
----------------------------------------------
class addTimer($name, $class, $function, $args, $interval, $runRightAway = false)
class getTimers()
void removeTimer($timer) (MUST be name)
mysql/postgre.php (Accessed with $this->db->)
---------------------------------------------
array queryFetch($query)
array fetchArray($object)
array fetchRow($object)
string getError()
bool isConnected()
int lastID()
int numRows($toFetch)
int numQueries()
void close()
object query($query)
dcc.php (Accessed with $this->dccClass->)
-----------------------------------------
array getDccList()
int getDownloadCount()
int getUploadCount()
int getChatCount()
int getBytesDown()
int getBytesUp()
int addChat($nick, $host, $port, $admin, $handler)
int addFile($nick, $host, $port, $type, $filename, $size)
int sendFile($nick, $file)
class getDcc($dcc)
void dccInform($text, $from = null)
chat.php
----------
void disconnect($msg = "")
void dccSend($msg)
file.php
----------
void disconnect($msg = "")
ini.php
----------
bool getError()
bool sectionExists($section)
bool deleteSection($section)
bool deleteVar($section, $var)
bool setIniVal($section, $var, $val)
bool writeIni()
array getSections()
array getVars($section)
array getSection($section)
array randomSection($num = 1)
array searchSections($search, $type = EXACT_MATCH)
array searchVars($section, $search, $type = EXACT_MATCH)
array searchSectionsByVar($var, $search, $type = EXACT_MATCH)
array searchVals($section, $search, $type = EXACT_MATCH)
mixed randomVar($section, $num = 1)
mixed getIniVal($section, $var)
int numSections()
int numVars($section)
Useful Static Routines
-----------------------
string socket::generatePostQuery($query, $host, $path, $httpVersion)
string socket::generateGetQuery($query, $host, $path, $httpVersion)
string irc::intToSizeString($size)
string irc::myStrToLower($text)
string irc::myStrToUpper($text)
string irc::timeFormat($time, $format)
string irc::randomHash()
array irc::multiLine($text)
=========================
Full Function Definitions
=========================
irc.php (Accessed with $this->ircClass->)
-----------------------------------------
-------------------------------
array parseModes($modeString)
-------------------------------
Mode strings usually come from the $line['params'] variable. However, they look like this:
+o-b Manick blah!*@*
This is a real mess to parse. Thus, this function takes the line and returns an array of each mode being operated. The format is as follows:
$modesArray = array(
[0] = array( 'ACTION' => '+',
'MODE' => 'o',
'EXTRA' => 'Manick',
'TYPE' => USER_MODE,
)
[1] = array( 'ACTION' => '-',
'MODE' => 'b',
'EXTRA' => 'blah!*@*',
'TYPE' => CHANNEL_MODE,
)
)
--------------------------------
array getMaintainedChannels()
--------------------------------
This will return an array of all the channels that php-irc will attempt to stay in. Every sixty seconds or so, the bot will attempt to join these channels if it is not currently in them. See 'maintainChannel()' and 'removeMaintain()' for more information.
--------------------------------
string getClientConf($var = "")
--------------------------------
Will return the corresponding value for the setting of $var in bot.conf. If $var == "", the full configuration array is returned as an array. Also, if the setting does not exist in the configuration, this function will return an empty string, "".
--------------------------------
string getNick()
--------------------------------
Returns the bots current, IRC recognized nick.
--------------------------------
string getServerConf($var)
--------------------------------
When connecting to a server, it will send these lines upon connection:
NETWORK=Rizon STATUSMSG=@%+ MODES=4 CHANLIMIT=#:30 MAXCHANNELS=30 MAXLIST=beI:100 MAXBANS=100 MAXTARGETS=4 NICKLEN=30 TOPICLEN=400 KICKLEN=400 CHANNELLEN=50 AWAYLEN=90 are supported by this server
CHANTYPES=# KNOCK EXCEPTS INVEX PREFIX=(ohv)@%+ CHANMODES=eIb,k,l,cimnpstMNORZ CASEMAPPING=rfc1459 CALLERID WALLCHOPS FNC PENALTY ETRACE are supported by this server
(These are just samples). So, you can retrieve the value for say, CHANMODES by doing this:
getServerConf("CHANMODES");
This will return a string, "eIb,k,l,cimnpstMNORZ".
----------------------------------
string getStatusString($status)
----------------------------------
After using getStatusRaw(), you can feed its value to this function, and it'll send back what it means, like "Connecting to Server..."
----------------------------------
string getClientIP($long = 1)
----------------------------------
This function returns the IP that the bot is using. if you specify $long as 1, then the ip address converted to long integer form is returned.
----------------------------------
class getChannelData($channel)
----------------------------------
This will search the channel database for the channel $channel, and then if it finds it, it will return that channels object. See the "channelLink" class in defines.php for member information.
----------------------------------
class getUserData($user, $channel = "")
----------------------------------
If a channel is specified, this will search the channel for the specified user's data. If it is found, it will return it as an object. See the "memberLink" class in defines.php for member information. If no channel is specified, this will search the entire channel database until the member is found, and then return that object.
----------------------------------
void disconnect()
----------------------------------
Disconnect the bot from the server...
----------------------------------
void setClientConfigVar($var, $value)
----------------------------------
This will overwrite a configuration setting from bot.conf that the bot is currently using. Self-explanitory.
----------------------------------
void joinChannel($chan)
----------------------------------
Join the channel $chan
----------------------------------
void sendRaw($text, $force = false)
----------------------------------
Send the raw text $text to the server. If $force is true, then the data is sent RIGHT away, it totally bypasses the queue, everything. It goes right to the send function, even through the socket class. Use this if you need lightning fast responses, such as writing a channel guard script.
----------------------------------
void privMsg($who, $msg, $queue = 1)
----------------------------------
$who = nick of user/name of channel
Send text to a channel or user. If $queue is 1, then the data will be put at the end of the text queue, if it is 0, it'll be pushed onto the beginning of the queue.
----------------------------------
void action($who, $msg, $queue = 1)
----------------------------------
Same as privMsg... emulates the /me command from mIRC
----------------------------------
void notice($who, $msg, $queue = 1)
----------------------------------
Same as privMsg, except a notice.
----------------------------------
void log($text)
----------------------------------
Write something to the log file.
----------------------------------
void maintainChannel($channel, $key = "")
----------------------------------
Attempt to stay in channel $channel. The bot will attempt rejoining every 60 seconds. You may specify a $key or leave it blank.
----------------------------------
void removeMaintain($channel)
----------------------------------
No longer attempt to say in channel $channel.
----------------------------------
void addQuery($host, $port, $query, $line, $class, $function)
----------------------------------
Also make sure you read the text about this function in the readme.txt, "Querying remote servers". This function takes 6 arguments.
$host = the host machine you want to connect to
$port = the port you want to connect to
$query = the raw data that will be sent to the server upon connection
$line = the $line argument that was passed to your module's function (just pass this right along with addQuery)
$class = usually '$this'..
$function = the function to run after the query is complete.
See sections 8 and 9 of readme.txt for information related to writing 'query' function types.
----------------------------------
int getStatusRaw()
----------------------------------
Returns an integer corresponding to current server status. See defines.php for meanings
----------------------------------
bool changeMode($chan, $act, $mode, $user)
----------------------------------
Changes the mode of $user on $chan
$act = either "+" or "-"
$mode = some mode, like "o" (ops), or "b" (ban), or something else.
$user = whatever the mode is being applied to
----------------------------------
bool isOnline($nick, $chan)
----------------------------------
Send back whether the nick is on the channel $chan (true or false)
----------------------------------
bool isMode($nick, $channel, $mode)
----------------------------------
See if some $user has some $mode activated on him in $channel
$user = nick of user
$mode = any mode, such as "o", "h", "v"
----------------------------------
bool isChanMode($channel, $mode, $extra = "")
----------------------------------
Sends back whether a specific mode is set in a channel
$mode = "b" or "s" or any other chan mode
$extra = (if you're using "b" for $mode, specify mask here)
----------------------------------
bool hasModeSet($chan, $nick, $modes)
----------------------------------
If any of the modes specified in "$modes" are set on a user in a channel, this will return true.
For instance:
If Manick is +vo in channel #manekian,
hasModeSet("#manekian", "Manick", "oh")
will return true. I'm asking php-irc if Manick is either mode o or mode h. Which he's mode o, so it returns true.
----------------------------------
bool hostMasksMatch($mask1, $mask2)
----------------------------------
Use this to determine whether two host masks match
----------------------------------
bool checkIgnore($mask)
----------------------------------
Check whether a hostmask is on the bot.conf ignore list.
socket.php (Accessed with $this->socketClass->)
-----------------------------------------------
----------------------------------
string getHost($sockInt)
----------------------------------
Return the IP address of the current socket integer of a connection. You can use connection::getSockInt() to get the sock int.
----------------------------------
string getQueue($sockInt)
----------------------------------
Retrieve the current read queue for a socket. The queue is then purged.
----------------------------------
string getQueueLine($sockInt)
----------------------------------
Get the next line in the queue, purging it from the read buffer and returning it (without crlf)
----------------------------------
int sendSocket($sockInt, $data)
----------------------------------
Send data to a socket
----------------------------------
int getSockStatus($sockInt)
----------------------------------
Get the status of a socket. See defines.php for list of constants.
----------------------------------
object getSockData($sockInt)
----------------------------------
Return the object that retains all data about socket "$sockInt". This is a php-irc maintained list.
----------------------------------
bool hasWriteQueue($sockInt)
----------------------------------
Return true or false depending on whether the bot has data to write to the socket. If this is true, you should restrain yourself from sending more data to the socket. An onWrite() call will be sent every time data is written, and each time "hasWriteQueue()" should be called to see if the queue is empty before sending data.
----------------------------------
bool hasLine($sockInt)
----------------------------------
Return true or false depending on if there is a newline in the buffer.
timers.php (Accessed with $this->timerClass->)
----------------------------------------------
----------------------------------
class addTimer($name, $class, $function, $args, $interval, $runRightAway = false)
----------------------------------
Add a timer. Please view the readme.txt documentation on this.
----------------------------------
class getTimers()
----------------------------------
This function will return a pointer to all the active timers. See the class "timer" in defines.php for member information.
----------------------------------
void removeTimer($timer) (MUST be timer name)
----------------------------------
Remove a timer $timer <-- can only be the name of timer, unlike in 2.1.1 where it could be the object itself.
mysql/postgre.php (Accessed with $this->db->)
---------------------------------------------
Some items for postgre aren't fully implemented or work yet... most notably queryFetch(), and some others. See postgre.php for more details.
----------------------------------
array queryFetch($query)
----------------------------------
Runs a query and returns the first row. Basically does query() and then mysql_fetch_array()
----------------------------------
array fetchArray($object)
----------------------------------
Does mysql_fetch_array() (see php.net for help)
----------------------------------
array fetchRow($object)
----------------------------------
Does mysql_fetch_row()
----------------------------------
string getError()
----------------------------------
Does mysql_error();
----------------------------------
bool isConnected()
----------------------------------
Returns whether the database is connected
----------------------------------
int lastID()
----------------------------------
Gets the last inserted 'id' row from the database.
----------------------------------
int numRows($toFetch)
----------------------------------
Does mysql_num_rows()
----------------------------------
int numQueries()
----------------------------------
sends back an integer of all the queries since the database class was spawned.
----------------------------------
void close()
----------------------------------
Closes the database connection
----------------------------------
object query($query)
----------------------------------
Runs a query, and returns the result as an object.
dcc.php (Accessed with $this->dccClass->)
-----------------------------------------
----------------------------------
array getDccList()
----------------------------------
Returns an array of all current dcc's in progress (chat and file)
----------------------------------
int getDownloadCount()
----------------------------------
Number of all current downloads
----------------------------------
int getUploadCount()
----------------------------------
Number of all current uploads
----------------------------------
int getChatCount()
----------------------------------
Number of all current dcc chat sessions
----------------------------------
int getBytesDown()
----------------------------------
Returns number of bytes downloaded since bot was started
----------------------------------
int getBytesUp()
----------------------------------
Returns number of bytes uploaded since bot was started
----------------------------------
int addChat($nick, $host, $port, $admin, $handler)
----------------------------------
Use this to create a dcc chat session.
$nick = nick of user to chat with
$host = host of user to chat with
$port = port to connect to
$admin = whether the user is admin (use admin dcc chat administration)
$handler = null, usually, unless you are creating a custom dcc chat handler. See readme.txt for more information.
If $host or $port is null, then addChat will think you are setting up a listening connection, otherwise it will try to connect to the host/port specified.
----------------------------------
int addFile($nick, $host, $port, $type, $filename, $size)
----------------------------------
Send a file to someone, or recieve a file.
$nick = nick of person sending/receiving file
$host = host of person sending/receiving file
$port = port of transfer
$type = either UPLOAD or DOWNLOAD
$filename = full filename with full path to file
$size = size of the file, can be null if its an UPLOAD type.
See readme.txt for more information regarding file transfers.
----------------------------------
int sendFile($nick, $file)
----------------------------------
Alias for addFile($nick, null, null, UPLOAD, $file, null)... basically just an easier way of sending files.
----------------------------------
class getDcc($dcc)
----------------------------------
$dcc = sockInt of the transfer
Returns dcc object for some sockInt, see fileserver.php for example.
----------------------------------
void dccInform($text)
----------------------------------
Send a message to all administrators
chat.php
----------
----------------------------------
void disconnect($msg = "")
----------------------------------
End the chat session
----------------------------------
void dccSend($msg)
----------------------------------
Send text to the user
file.php
----------
----------------------------------
void disconnect($msg = "")
----------------------------------
End the dcc file transfer session
ini.php
----------
Please see readme.txt for more information on create ini objects.
----------------------------------
bool getError()
----------------------------------
An ini object will not operate after a fatal error. You can use this to retrieve whether a fatal error has happened.
----------------------------------
bool sectionExists($section)
----------------------------------
Return true if the section exists, or false if it doesn't.
----------------------------------
bool deleteSection($section)
----------------------------------
Delete a section.
----------------------------------
bool deleteVar($section, $var)
----------------------------------
Delete a var in a section.
----------------------------------
bool setIniVal($section, $var, $val)
----------------------------------
Set the '$var' value '$val' in section $section.
----------------------------------
bool writeIni()
----------------------------------
Write all of the ini changes to a file
----------------------------------
array getSections()
----------------------------------
Return an array of all the section names.
----------------------------------
array getVars($section)
----------------------------------
Return all the vars/vals in an associative array for $section.
----------------------------------
array getSection($section)
----------------------------------
Alias for getVars()
----------------------------------
array randomSection($num = 1)
----------------------------------
Does same as getVars(), but returns random section. $num is the number of random sections to return. Default 1.
----------------------------------
array searchSections($search, $type = EXACT_MATCH)
----------------------------------
Search section names for $search, can do 4 types of searches: Exact, and, or, contains:
Exact: the section and search match completely
And: the section name contains all componants of search (separated by space)
Or: the section name contains at least one of the componants of search (separated by space)
Contains: the section contains the search string within it
----------------------------------
array searchVars($section, $search, $type = EXACT_MATCH)
----------------------------------
Search the variable names of a section for $search, same as searchSections() except with vars.
----------------------------------
array searchSectionsByVar($var, $search, $type = EXACT_MATCH)
----------------------------------
In every section that has '$var' as a varaible, see if the var's value matches $search.
----------------------------------
array searchVals($section, $search, $type = EXACT_MATCH)
----------------------------------
Search all the values of a section for '$search'. Return list of vars.
----------------------------------
mixed randomVar($section, $num = 1)
----------------------------------
Return a random var in a section.
----------------------------------
mixed getIniVal($section, $var)
----------------------------------
Retrieve an ini value '$var' in section '$section'. False if non-existant.
----------------------------------
int numSections()
----------------------------------
Return number of sections.
----------------------------------
int numVars($section)
----------------------------------
Return number of vars in a section.
Useful Static Routines
-----------------------
----------------------------------
string socket::generatePostQuery($query, $host, $path, $httpVersion = "")
----------------------------------
Takes a query, like so:
$query = "search=blah&somesetting=5";
And turns it into a POST query you can send off to addQuery
$host = host of server you will be accessing, like "www.manekian.com"
$path = script + path of script you will be accessing, like "/search.php" or "/index.php", or just "/"
$httpVersion, you can ignore this, but sometimes you might want to set this to "1.0"
----------------------------------
string socket::generateGetQuery($query, $host, $path, $httpVersion)
----------------------------------
Same as generatePostQuery except with Get String
----------------------------------
string irc::intToSizeString($size)
----------------------------------
Takes a large size, and then changes it into MB, GB, KB, depending on the size.
----------------------------------
string irc::myStrToLower($text)
----------------------------------
RFC1459 complient strtolower()
----------------------------------
string irc::myStrToUpper($text)
----------------------------------
RFC1459 complient strtoupper()
----------------------------------
string irc::timeFormat($time, $format)
----------------------------------
Feed this thing a timestring, and a format, and it'll send back a user friendly representation of the timestamp.
for example:
timeFormat(5, "%d days, %h hours, %m minutes, %s seconds")
This will return a string, "0 days, 0 hours, 0 minutes, 5 seconds".
----------------------------------
string irc::randomHash()
----------------------------------
Generates a 32 char random md5 hash
----------------------------------
array irc::multiLine($text)
----------------------------------
Feed this a huge text string, and it will split it up into 255 max char increment lines you can send to the irc server. It returns an array of all of these.