Class: Plugins::Silly

Inherits:
Object
  • Object
show all
Includes:
Cinch::Helpers, Cinch::Plugin
Defined in:
lib/Zeta/plugins/silly.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Cinch::Plugin

#check?, #log2chan

Constructor Details

#initialize(*args) ⇒ Silly

Returns a new instance of Silly.



25
26
27
28
# File 'lib/Zeta/plugins/silly.rb', line 25

def initialize *args
  super
  @pokers = {}
end

Instance Attribute Details

#pokersObject (readonly)

Returns the value of attribute pokers.



23
24
25
# File 'lib/Zeta/plugins/silly.rb', line 23

def pokers
  @pokers
end

Instance Method Details

#execute_botinsult(m) ⇒ Object



52
53
54
55
# File 'lib/Zeta/plugins/silly.rb', line 52

def execute_botinsult(m)

  m.reply ["Stupid human!", "Dumb human!", "Stupid meatbag.", "Silly human, your insults cannot harm me!", "get rekt", "u fkn w0t m8"].sample
end

#execute_userproblem(m) ⇒ Object



174
175
176
# File 'lib/Zeta/plugins/silly.rb', line 174

def execute_userproblem(m)
  m.reply ["user error.", "working as intended", "Status: WONTFIX", "PEBKAC issue", "ID:10T Error"].sample
end

#halloween(m, tz = nil) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/Zeta/plugins/silly.rb', line 72

def halloween(m, tz = nil)
  tz ||= "-00:00"
  tz = tzparser(tz)
  begin
    today = Time.now.localtime(tz)
    hw = Time.new(today.year, 10, 31, 0, 0, 0, tz)
    hw = hw.next_year if hw.to_date.past?
    message = if hw.to_date == today.to_date
                "THIS IS HALLOWEEN!"
              else
                "There's #{ChronicDuration.output(hw.to_i - today.to_i, format: :long)} until Hallow's Eve!"
              end
  rescue ArgumentError => ae
    message = ae.message
  ensure
    m.reply message, true
  end
end

#heavymetalize(m, s) ⇒ Object



168
169
170
# File 'lib/Zeta/plugins/silly.rb', line 168

def heavymetalize(m, s)
  m.reply s.tr('AEIOUaeiouyYWwXx', 'ÄËÏÖÜäëïöüÿŸẄẅẌẍ')
end

#listen_poke(m, thebot) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/Zeta/plugins/silly.rb', line 32

def listen_poke(m, thebot)

  if User(thebot) == @bot
    @pokers[m.user] = 0 if !@pokers.include?(m.user)
    @pokers[m.user] += 1
    case @pokers[m.user]
      when 1..3
        m.reply "Do NOT poke the bot!"
      when 4
        m.reply "I said, do NOT poke the bot!"
      when 5
        msg = ["WHAT ARE YOU, AN IDIOT? I SAID DO NOT POKE ME!!", "THIS! IS! SPARTA!!"].sample
        m.channel.kick m.user, ["WHAT ARE YOU, AN IDIOT? I SAID DO NOT POKE ME!!", "THIS! IS! SPARTA!!"].sample
        @pokers.delete(m.user)
    end
  end
end

#mayan(m) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/Zeta/plugins/silly.rb', line 153

def mayan(m)
  msd = (Date.today.jd - Date.new(1, 1, 1).jd) + 1137142
  lc = {
      baktun: (msd - (msd % 144000)) / 144000,
      katun: ((msd - (msd % 7200)) / 7200) % 20,
      tun: ((msd - (msd % 360)) / 360) % 20,
      uinal: ((msd - (msd % 20)) / 20) % 18,
      kin: (msd % 20)
  }

  m.reply '%<baktun>s.%<katun>s.%<tun>s.%<uinal>s.%<kin>s' % lc
end

#newyear(m, tz = nil) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/Zeta/plugins/silly.rb', line 116

def newyear(m, tz = nil)
  tz ||= "-00:00"
  tz = tzparser(tz)
  begin
    today = Time.now.localtime(tz)
    nyear = Time.new(today.year.succ, 1, 1, 0, 0, 0, tz)
    #nyear = nyear.next_year if nyear.to_date.past?
    message = if nyear.to_date == today.to_date
                "Happy New Year #{today.year}!"
              else
                "There's #{ChronicDuration.output(nyear.to_i - today.to_i, format: :long)} until #{nyear.year}!"
              end
  rescue ArgumentError => ae
    message = ae.message
  ensure
    m.reply message, true
  end
end

#tz(m, tz = nil) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/Zeta/plugins/silly.rb', line 138

def tz(m, tz = nil)
  tz ||= "-00:00"
  tz = tzparser(tz)
  begin
    today = Time.now.localtime(tz)
    message = today.to_s
  rescue ArgumentError => ae
    message = ae.message
  ensure
    m.reply message, true
  end
end

#tzparser(tz) ⇒ Object



57
58
59
60
61
62
63
64
65
66
# File 'lib/Zeta/plugins/silly.rb', line 57

def tzparser(tz)
  prefix = (tz[0] !~ /(\+|-)/ ? "+" : "")
  suffix = (tz =~ /^(?:\+|-)?(\d{1,2})$/ ? ":00" : "")
  regexp = /^(\+|-)?(\d{1,2})(?::(\d{1,2}))?$/
  if tz =~ regexp
    prefix + tz.gsub(regexp) { |match| (!!$1 ? $1 : "") + $2.rjust(2, "0") + (!!$3 ? ":"+$3.rjust(2, "0") : "") } + suffix
  else
    raise ArgumentError, "A valid timezone was not supplied."
  end
end

#xmas(m, tz = nil) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/Zeta/plugins/silly.rb', line 94

def xmas(m, tz = nil)
  tz ||= "-00:00"
  tz = tzparser(tz)
  begin
    today   = Time.now.localtime(tz)
    xmas    = Time.new(today.year, 12, 25, 0, 0, 0, tz)
    xmas    = xmas.next_year if xmas.to_date.past?
    message = if xmas.to_date == today.to_date
                "Merry Christmas!"
              else
                "There's #{ChronicDuration.output(xmas.to_i - today.to_i, format: :long)} until Christmas!"
              end
  rescue ArgumentError => ae
    message = ae.message
  ensure
    m.reply message, true
  end
end