Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 79 lines (62 sloc) 2.306 kb
a34ce66 @alloy Add a !help banner.
alloy authored
1 # encoding: UTF-8
ba41b5e @alloy Before listing assigned/marked tickets, give a summary.
alloy authored
2
41d5b48 @alloy Initial commit/
alloy authored
3 $:.unshift File.expand_path("../../vendor/cinch/lib", __FILE__)
4 require "cinch"
aa19332 @alloy Add bot commands for all Trac methods.
alloy authored
5 require "macruby_bugmash_bot/trac"
5df5aaf @alloy Setup spec env.
alloy authored
6
7 bot = Cinch::Bot.new do
8 configure do |c|
aa19332 @alloy Add bot commands for all Trac methods.
alloy authored
9 c.server = "irc.freenode.org"
ef60a13 @alloy Force the feed string to UTF-8, always coerce an ID to an int before …
alloy authored
10 c.nick = "BugMash-bot"
dfca475 @alloy Might be more fun if it actually joins the right channel...
alloy authored
11 c.channels = ["#macruby"]
aa19332 @alloy Add bot commands for all Trac methods.
alloy authored
12
13 @trac = Trac.new
5df5aaf @alloy Setup spec env.
alloy authored
14 end
15
a34ce66 @alloy Add a !help banner.
alloy authored
16 HELP = [
5caec92 @alloy Show info about a ticket.
alloy authored
17 "‘#<id>’ Get info about a ticket.",
a34ce66 @alloy Add a !help banner.
alloy authored
18 "‘!gimme’ This command will tell you of a single ticket that is available.",
19 "‘!work <id>’ This command tells the bot that you are now working on a ticket.",
20 "‘!stop <id>’ This command tells the bot that you are no longer working on a ticket.",
21 "‘!status <id>’ This command asks the bot the status of a particular ticket. It will respond by saying who's working on it.",
22 "‘!review <id>’ Marks the ticket for review. MacRuby core will monitor this to see what's ready to be reviewed.",
23 "‘!unreview <id>’ Unmarks the ticket to be reviewed.",
24 "‘!me’ Private messages you telling you the number of tickets you're working on and lists them off.",
25 "‘!marked’ Private messages you telling you what the tickets are that are ready to be reviewed."
26 ]
27
28 on :channel, "!help" do |m|
29 HELP.each { |msg| m.user.send(msg) }
5df5aaf @alloy Setup spec env.
alloy authored
30 end
aa19332 @alloy Add bot commands for all Trac methods.
alloy authored
31
aa646ce @alloy Quickly add in a total open ticket count.
alloy authored
32 # TODO move this out
33 on :channel, "!total" do |m|
34 m.reply "There are a total of #{DB.tickets.filter(:closed => false).count} open tickets."
35 end
36
aa19332 @alloy Add bot commands for all Trac methods.
alloy authored
37 on :channel, "!gimme" do |m|
38 m.reply @trac.open_ticket
39 end
40
5caec92 @alloy Show info about a ticket.
alloy authored
41 on :channel, /^#(\d+)/ do |m, id|
42 m.reply @trac.ticket_info(id, m.user.nick)
43 end
44
4903a3d @alloy Make Vincent happy ;)
alloy authored
45 on :channel, /^!work #?(\d+)/ do |m, id|
aa19332 @alloy Add bot commands for all Trac methods.
alloy authored
46 m.reply @trac.assign_ticket(id, m.user.nick)
47 end
48
4903a3d @alloy Make Vincent happy ;)
alloy authored
49 on :channel, /^!stop #?(\d+)/ do |m, id|
aa19332 @alloy Add bot commands for all Trac methods.
alloy authored
50 m.reply @trac.resign_from_ticket(id, m.user.nick)
51 end
52
4903a3d @alloy Make Vincent happy ;)
alloy authored
53 on :channel, /^!status #?(\d+)/ do |m, id|
aa19332 @alloy Add bot commands for all Trac methods.
alloy authored
54 m.reply @trac.ticket_status(id, m.user.nick)
55 end
56
4903a3d @alloy Make Vincent happy ;)
alloy authored
57 on :channel, /^!review #?(\d+)/ do |m, id|
aa19332 @alloy Add bot commands for all Trac methods.
alloy authored
58 m.reply @trac.mark_for_review(id, m.user.nick)
59 end
60
4903a3d @alloy Make Vincent happy ;)
alloy authored
61 on :channel, /^!unreview #?(\d+)/ do |m, id|
aa19332 @alloy Add bot commands for all Trac methods.
alloy authored
62 m.reply @trac.unmark_for_review(id, m.user.nick)
63 end
64
65 on :message, "!me" do |m|
66 @trac.user(m.user.nick).each do |msg|
67 m.user.send(msg)
68 end
69 end
70
a34ce66 @alloy Add a !help banner.
alloy authored
71 on :message, "!marked" do |m|
aa19332 @alloy Add bot commands for all Trac methods.
alloy authored
72 @trac.marked_for_review.each do |msg|
73 m.user.send(msg)
74 end
75 end
5df5aaf @alloy Setup spec env.
alloy authored
76 end
77
78 bot.start
Something went wrong with that request. Please try again.