Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 79 lines (62 sloc) 2.306 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
# encoding: UTF-8

$:.unshift File.expand_path("../../vendor/cinch/lib", __FILE__)
require "cinch"
require "macruby_bugmash_bot/trac"

bot = Cinch::Bot.new do
  configure do |c|
    c.server = "irc.freenode.org"
    c.nick = "BugMash-bot"
    c.channels = ["#macruby"]

    @trac = Trac.new
  end

  HELP = [
    "‘#<id>’ Get info about a ticket.",
    "‘!gimme’ This command will tell you of a single ticket that is available.",
    "‘!work <id>’ This command tells the bot that you are now working on a ticket.",
    "‘!stop <id>’ This command tells the bot that you are no longer working on a ticket.",
    "‘!status <id>’ This command asks the bot the status of a particular ticket. It will respond by saying who's working on it.",
    "‘!review <id>’ Marks the ticket for review. MacRuby core will monitor this to see what's ready to be reviewed.",
    "‘!unreview <id>’ Unmarks the ticket to be reviewed.",
    "‘!me’ Private messages you telling you the number of tickets you're working on and lists them off.",
    "‘!marked’ Private messages you telling you what the tickets are that are ready to be reviewed."
  ]

  on :channel, "!help" do |m|
    HELP.each { |msg| m.user.send(msg) }
  end

  # TODO move this out
  on :channel, "!total" do |m|
    m.reply "There are a total of #{DB.tickets.filter(:closed => false).count} open tickets."
  end

  on :channel, "!gimme" do |m|
    m.reply @trac.open_ticket
  end

  on :channel, /^#(\d+)/ do |m, id|
    m.reply @trac.ticket_info(id, m.user.nick)
  end

  on :channel, /^!work #?(\d+)/ do |m, id|
    m.reply @trac.assign_ticket(id, m.user.nick)
  end

  on :channel, /^!stop #?(\d+)/ do |m, id|
    m.reply @trac.resign_from_ticket(id, m.user.nick)
  end

  on :channel, /^!status #?(\d+)/ do |m, id|
    m.reply @trac.ticket_status(id, m.user.nick)
  end

  on :channel, /^!review #?(\d+)/ do |m, id|
    m.reply @trac.mark_for_review(id, m.user.nick)
  end

  on :channel, /^!unreview #?(\d+)/ do |m, id|
    m.reply @trac.unmark_for_review(id, m.user.nick)
  end

  on :message, "!me" do |m|
    @trac.user(m.user.nick).each do |msg|
      m.user.send(msg)
    end
  end

  on :message, "!marked" do |m|
    @trac.marked_for_review.each do |msg|
      m.user.send(msg)
    end
  end
end

bot.start
Something went wrong with that request. Please try again.