summaryrefslogtreecommitdiff
path: root/scripts/examples
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-03-10 21:28:38 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-03-10 21:28:38 +0000
commit03c71116e044fda9d99e827a4ffb0652d508abb5 (patch)
treedf36506fb09ad6563feaf394a0a47728348cadd6 /scripts/examples
parent1855e6cc5c84ec861bf1301c09841cb2fd9ad718 (diff)
downloadirssi-03c71116e044fda9d99e827a4ffb0652d508abb5.zip
added/removed some default scripts
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2569 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'scripts/examples')
-rw-r--r--scripts/examples/command.pl23
-rw-r--r--scripts/examples/msg-event.pl41
-rw-r--r--scripts/examples/redirect.pl40
3 files changed, 104 insertions, 0 deletions
diff --git a/scripts/examples/command.pl b/scripts/examples/command.pl
new file mode 100644
index 00000000..77a9d7fb
--- /dev/null
+++ b/scripts/examples/command.pl
@@ -0,0 +1,23 @@
+# Example how to create your own /commands:
+
+# /HELLO <nick> - sends a "Hello, world!" to given nick.
+
+use Irssi;
+use strict;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "1.00";
+%IRSSI = (
+ authors => 'Timo Sirainen',
+ name => 'command',
+ description => 'Command example',
+ license => 'Public Domain'
+);
+
+sub cmd_hello {
+ my ($data, $server, $channel) = @_;
+
+ $server->command("/msg $data Hello, world!");
+}
+
+Irssi::command_bind('hello', 'cmd_hello');
diff --git a/scripts/examples/msg-event.pl b/scripts/examples/msg-event.pl
new file mode 100644
index 00000000..53174e23
--- /dev/null
+++ b/scripts/examples/msg-event.pl
@@ -0,0 +1,41 @@
+# Example how to react on specific messages:
+
+# !reverse <text> sends back the text reversed.
+
+use Irssi;
+use strict;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "1.00";
+%IRSSI = (
+ authors => 'Timo Sirainen',
+ name => 'msg-event',
+ description => 'Event example',
+ license => 'Public Domain'
+);
+
+sub event_privmsg {
+ # $server = server record where the message came
+ # $data = the raw data received from server, with PRIVMSGs it is:
+ # "target :text" where target is either your nick or #channel
+ # $nick = the nick who sent the message
+ # $host = host of the nick who sent the message
+ my ($server, $data, $nick, $host) = @_;
+
+ # split data to target/text
+ my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
+
+ # skip lines not beginning with !reverse
+ return if ($text !~ /!reverse (.*)/);
+ $text = $1;
+
+ if (!$server->ischannel($target)) {
+ # private message, $target contains our nick, so we'll need
+ # to change it to $nick
+ $target = $nick;
+ }
+
+ $server->command("notice $target reversed $text = ".reverse($text));
+}
+
+Irssi::signal_add('event privmsg', 'event_privmsg');
diff --git a/scripts/examples/redirect.pl b/scripts/examples/redirect.pl
new file mode 100644
index 00000000..6a7e94cc
--- /dev/null
+++ b/scripts/examples/redirect.pl
@@ -0,0 +1,40 @@
+# Example how to do redirections, we'll grab the output of /WHOIS:
+
+# /RN - display real name of nick
+
+use Irssi;
+use Irssi::Irc;
+use strict;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "1.00";
+%IRSSI = (
+ authors => 'Timo Sirainen',
+ name => 'redirect',
+ description => 'Redirection example',
+ license => 'Public Domain'
+);
+
+sub cmd_realname {
+ my ($data, $server, $channel) = @_;
+
+ # ignore all whois replies except "No such nick" or the
+ # first line of the WHOIS reply
+ $server->redirect_event('whois', 1, $data, -1, '', {
+ 'event 402' => 'event 402',
+ 'event 401' => 'event 401',
+ 'event 311' => 'redir whois',
+ '' => 'event empty' });
+
+ $server->send_raw("WHOIS :$data");
+}
+
+sub event_rn_whois {
+ my ($num, $nick, $user, $host, $empty, $realname) = split(/ +/, $_[1], 6);
+ $realname =~ s/^://;
+
+ Irssi::print("%_$nick%_ is $realname");
+}
+
+Irssi::command_bind('rn', 'cmd_realname');
+Irssi::signal_add('redir whois', 'event_rn_whois');