forked from slipcon/jira-pidgin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjira.pl
More file actions
executable file
·50 lines (39 loc) · 1.3 KB
/
jira.pl
File metadata and controls
executable file
·50 lines (39 loc) · 1.3 KB
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
use Purple;
use Data::Dumper;
my $jiraurl = "http://jira.myhost.com/browse";
%PLUGIN_INFO = (
perl_api_version => 2,
name => "Jira Plugin",
version => "0.1",
summary => "Auto-link to Jira tickets",
description => "Create links automatically to Jira issues",
author => "Scott Lipcon <slipcon\@gmail.com",
url => "http://pidgin.im",
load => "plugin_load",
unload => "plugin_unload"
);
sub plugin_init {
return %PLUGIN_INFO;
}
sub plugin_load {
my $plugin = shift;
Purple::Debug::info("jiraplugin", "plugin_load() - Jira Plugin Loaded.\n");
my $convs_handle = Purple::Conversations::get_handle();
# Connect the perl sub 'receiving_im_msg_cb' to the event
# 'receiving-im-msg'
Purple::Signal::connect($convs_handle, "receiving-im-msg",
$plugin,
\&receiving_im_msg_cb, 0);
}
sub plugin_unload {
my $plugin = shift;
Purple::Debug::info("jiraplugin", "plugin_unload() - Jira Plugin Unloaded.\n");
}
sub receiving_im_msg_cb {
my ($account, $who, $msg, $conv, $flags, $data) = @_;
my $accountname = $account->get_username();
Purple::Debug::info("jiraplugin", "Message is \'$msg\'\n");
return if ($msg =~ /https?:\/\//);
$msg =~ s/([[:alpha:]]\w+)-(\d+)\b/<a href=\"$jiraurl\/$1-$2\"\>$1-$2\<\/a\>/g;
$_[2] = $msg;
}