Skip to content

Instantly share code, notes, and snippets.

@sarguru
Created August 3, 2012 15:17
Show Gist options
  • Save sarguru/3248563 to your computer and use it in GitHub Desktop.
Save sarguru/3248563 to your computer and use it in GitHub Desktop.
hubot-rt
#!/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"
};
# 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