cinchrb / cinch

The IRC Bot Building Framework
http://www.rubydoc.info/gems/cinch
MIT License
1k stars 180 forks source link

custom quit message #218

Closed bazz1tv closed 8 years ago

bazz1tv commented 8 years ago

Is this already possible?

petertseng commented 8 years ago

yup, http://www.rubydoc.info/gems/cinch/Cinch/Bot#quit-instance_method

works for me:

require 'cinch'

class Quit
  include Cinch::Plugin

  match(/q (.+)/, method: :q)

  def q(m, qm)
    m.bot.quit(qm)
  end
end

bot = Cinch::Bot.new do
  configure do |c|
    c.nick = 'QuitBot'
    c.server = 'irc.snoonet.org'
    c.port = 6697
    c.ssl.use = true
    c.channels = ['#examplechannel']
    c.verbose = true
    c.plugins.plugins = [
      Quit,
    ]
  end
end

bot.start

(It's admitted by me that the example misses two lines that I used, my bot's sasl username and password, but that's not relevant to the example)

04:32:00 <@pt> !q a
04:32:05 -!- QuitBot [cinch@user/pt/bot/ptbot] has quit [Quit: a]
bazz1tv commented 8 years ago

Nice, I just realize I want to have a custom particular quit message also when I quit my bot via ctrl-c signal. I think I will be able to come up with that on my own. I feel comfortable closing this issue then. Thanks 😃