Advertisement
Azure

This ruby file is silly!

Dec 4th, 2011
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.53 KB | None | 0 0
  1. require 'date'
  2.  
  3. module Plugins
  4.     class Silly
  5.         include Cinch::Plugin
  6.         set(
  7.             plugin_name: "silly",
  8.             help: "You know, silly stuff.")
  9.    
  10.     def action_match ctcp_args, match, compare = true
  11.       if compare
  12.         !!(ctcp_args.join(" ") =~ match) if ctcp_args.is_a?(Array) && match.is_a?(Regexp)
  13.       else
  14.         ctcp_args.join(" ").match(match) if ctcp_args.is_a?(Array) && match.is_a?(Regexp)
  15.       end
  16.     end
  17.  
  18.     listen_to :action, method: :listen_poke
  19.     def listen_poke m
  20.       return unless action_match(m.ctcp_args, %r{^pokes (\S+)})
  21.       if action_match(m.ctcp_args, %r{^pokes (\S+)}, false)[1].casecmp(@bot.nick) == 0
  22.         m.reply "Do NOT poke the bot!"
  23.       end
  24.     end
  25.  
  26.     match /dumb bot/i, method: :execute_botinsult, use_prefix: false
  27.     def execute_botinsult (m); m.reply ["Stupid human!","Dumb human!","Stupid meatbag."].sample if m.user.nick != "TempTina"; end
  28.  
  29.     match /xmas/, method: :xmas
  30.     def xmas (m)
  31.       today = Date.today
  32.       xmas = Date.new(today.year,12,25)
  33.       xmas = xmas.next_year if (xmas <=> today) == -1
  34.       days_until_xmas = (xmas - today).to_i
  35.  
  36.       def sinplur (num, singular, plural); num != 1 ? plural : singular; end;
  37.  
  38.       m.reply((today == xmas ? format([:red, :green].sample, :bold, "Merry ")+format([:red, :green].sample, :bold, "Christmas")+", #{m.user.nick}!" : "There #{sinplur(days_until_xmas,"is","are")} #{format([:red, :green].sample, :bold, days_until_xmas)} #{sinplur(days_until_xmas,"more day","days")} until Christmas!"))
  39.     end
  40.  
  41.     end
  42. end
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement