Created
August 3, 2012 15:17
-
-
Save sarguru/3248563 to your computer and use it in GitHub Desktop.
hubot-rt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Error qw(:try); | |
use RT::Client::REST; | |
my $id = $ARGV[0]; | |
my $rt = RT::Client::REST->new( | |
server => 'http://RTURL', | |
timeout => 30, | |
); | |
try { | |
$rt->login(username => 'RT_USER', password => 'RT_PASS'); | |
} catch Exception::Class::Base with { | |
die "problem logging in: ", shift->message; | |
}; | |
try { | |
$ticket = $rt->show(type => 'ticket', id => $id); | |
my ( $queue, $subject, $owner, $created, $lastupdated, @requestors ) = ( $ticket->{Queue}, $ticket->{Subject}, $ticket->{Owner}, $ticket->{Created}, $ticket->{LastUpdated}, $ticket->{requestors} ); | |
print "Ticket \"$subject\" in queue $queue, was created on $created , last updated on $lastupdated, and is owned by $owner\n"; | |
} catch RT::Client::REST::Exception with { | |
print "something went wrong" | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ticket details | |
# | |
# ticket details <ticketid> - show ticket details | |
exec = require('child_process').exec; | |
module.exports = (robot) -> | |
robot.respond /ticket details (.*)/i, (msg) -> | |
add = msg.match[1] | |
script = "/opt/rt/ticket.pl #{add}" | |
console.log(script) | |
child = exec script,(error,stdout,stderr)-> | |
msg.send stdout + "\n" + stderr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment