-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathHelloWorld.pm
64 lines (43 loc) · 1.71 KB
/
HelloWorld.pm
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
# We define our plugin class
package HelloWorld;
# We use strict Perl syntax for cleaner code
use strict;
# We use the SPADS plugin API module
use SpadsPluginApi;
# This is the first version of the plugin
my $pluginVersion='0.1';
# This plugin is compatible with any SPADS version which supports plugins
# (only SPADS versions >= 0.11 support plugins)
my $requiredSpadsVersion='0.11';
# This is how SPADS gets our version number (mandatory callback)
sub getVersion { return $pluginVersion; }
# This is how SPADS determines if the plugin is compatible (mandatory callback)
sub getRequiredSpadsVersion { return $requiredSpadsVersion; }
# This is our constructor, called when the plugin is loaded by SPADS (mandatory callback)
sub new {
# Constructors take the class name as first parameter
my $class=shift;
# We create a hash which will contain the plugin data
my $self = {};
# We instanciate this hash as an object of the given class
bless($self,$class);
# We call the API function "slog" to log a notice message (level 3) when the plugin is loaded
slog("HelloWorld plugin loaded (version $pluginVersion)",3);
# We return the instantiated plugin
return $self;
}
sub onPrivateMsg {
# $self is the plugin object (first parameter of all plugin callbacks)
# $userName is the name of the user sending the private message
# $message is the message sent by the user
my ($self,$userName,$message)=@_;
# We check the message sent by the user is "Hello"
if($message eq 'Hello') {
# We send our wonderful Hello World message
sayPrivate($userName,'Hello World');
}
# We return 0 because we don't want to filter out private messages
# for other SPADS processing
return 0;
}
1;