Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit a8eb651

Browse files
committed
Initial Commit
0 parents  commit a8eb651

11 files changed

Lines changed: 1751 additions & 0 deletions

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
text eol=lf

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
javascript.so

examples/hooks.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
SCRIPT_NAME = "hooks";
3+
SCRIPT_VER = "1";
4+
SCRIPT_DESC = "examples of hooks";
5+
6+
var timer_hook;
7+
8+
function test_cb (words)
9+
{
10+
if (words[1] == 'stop')
11+
{
12+
unhook (timer_hook);
13+
print ('timer unhooked');
14+
}
15+
else
16+
print ("stop calling test it doesn't do anything!");
17+
18+
return EAT_ALL; // Don't let anything else use /test
19+
}
20+
21+
function timer_cb ()
22+
{
23+
command ('test');
24+
25+
return true; // return true to continue the timer
26+
}
27+
28+
hook_command ('test', test_cb, 'there is no help for test =(');
29+
timer_hook = hook_timer (10000, timer_cb); // 10 sec

examples/misc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
SCRIPT_NAME = "misc";
3+
SCRIPT_VER = "1";
4+
SCRIPT_DESC = "examples";
5+
6+
if (nickcmp (get_info ('nick'), 'TingPing') == 0)
7+
print ('\00320You are cool!');
8+
else
9+
print (strip('\002\00319You are not cool, no colors for you.', 1));

examples/prefs.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
SCRIPT_NAME = "prefs";
3+
SCRIPT_VER = "1";
4+
SCRIPT_DESC = "example of pluginpref";
5+
6+
function pref_cb (word, word_eol)
7+
{
8+
switch (word[1])
9+
{
10+
case "add":
11+
if (set_pluginpref (word[2], word_eol[3]))
12+
print (word[2] + ' added');
13+
break;
14+
15+
case "delete":
16+
if (del_pluginpref (word[2]))
17+
print (word[2] + ' deleted or never existed');
18+
break;
19+
20+
case "list":
21+
print (list_pluginpref ());
22+
break;
23+
24+
case "get":
25+
print (get_pluginpref (word[2]));
26+
break;
27+
28+
default:
29+
command ('help pref');
30+
}
31+
}
32+
33+
hook_command ('pref', pref_cb, "USAGE: pref add <var> <val>\n delete <var>\n get <var>\n list");

examples/regex.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
SCRIPT_NAME = "regex";
3+
SCRIPT_VER = "1";
4+
SCRIPT_DESC = "example of regex";
5+
6+
var re = new RegExp(".*(nickserv|ns)\sidentify\s\w+");
7+
8+
function chan_cb (params)
9+
{
10+
if (params[1].search(re)) // message
11+
{
12+
command('say ' + params[0] + ', You should change your password.'); // nick
13+
}
14+
}
15+
16+
hook_print ("Channel Message", chan_cb);

examples/time.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
SCRIPT_NAME = "time";
3+
SCRIPT_VER = "1";
4+
SCRIPT_DESC = "example of using times";
5+
6+
var date = new Date();
7+
var now = date.getTime();
8+
9+
for each (user in get_list('users'))
10+
{
11+
let usertime = user.lasttalk.getTime();
12+
13+
if (now - usertime < 60 * 1000)
14+
print (user.nick + ' has spoke recently.');
15+
}

0 commit comments

Comments
 (0)