Class: Cinch::Plugins::Octospy

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin, Job, Recording
Defined in:
lib/cinch/plugins/octospy.rb,
lib/cinch/plugins/octospy/job.rb,
lib/cinch/plugins/octospy/recording.rb

Defined Under Namespace

Modules: Job, Recording

Instance Method Summary collapse

Methods included from Job

included, #restart, #restart!, #restart_with_message, #start, #start_with_message, #stop, #stop_with_message

Methods included from Recording

#clear_watched_repositories, included, #show_watched_repositories, #unwatch_repositories, #unwatch_repository, #watch_repositories, #watch_repository

Instance Method Details

#greet(m) ⇒ Object



23
24
25
# File 'lib/cinch/plugins/octospy.rb', line 23

def greet(m)
  m.reply "hi #{m.user.nick}"
end

#join(m, channel) ⇒ Object



35
36
37
38
39
# File 'lib/cinch/plugins/octospy.rb', line 35

def join(m, channel)
  ch = "##{channel.gsub('#', '')}"
  Channel(ch).join
  m.reply "#{ch} joined!"
end

#join_on_invite(m) ⇒ Object



69
70
71
# File 'lib/cinch/plugins/octospy.rb', line 69

def join_on_invite(m)
  Channel(m.channel).join
end

#part(m, channel) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/cinch/plugins/octospy.rb', line 41

def part(m, channel)
  channel ||= m.channel
  if channel
    ch = "##{channel.gsub('#', '')}"
    Channel(ch).part
    m.reply "#{ch} parted!" unless ch == m.channel
  end
end

#pong(m) ⇒ Object



27
28
29
# File 'lib/cinch/plugins/octospy.rb', line 27

def pong(m)
  m.reply "#{m.user.nick}: pong"
end

#rename(m) ⇒ Object



31
32
33
# File 'lib/cinch/plugins/octospy.rb', line 31

def rename(m)
  @bot.nick += '_'
end

#show_commands(m) ⇒ Object



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

def show_commands(m)
  m.reply "#{m.bot.name}:"
  @handlers.each do |handler|
    pattern = handler.pattern.pattern
    command = case pattern.class.name
      when 'Regexp' then pattern.source unless pattern.source == ''
      when 'String' then pattern unless pattern.empty?
      end
    m.reply " #{command}" if command
  end
end

#show_status(m) ⇒ Object



50
51
52
53
54
55
# File 'lib/cinch/plugins/octospy.rb', line 50

def show_status(m)
  @bot.channels.each.with_index(1) do |channel, i|
    number = ::Octospy::Recordable.channel(channel).repos.count
    m.reply "#{"%02d" % i} #{channel}: #{number} repo#{'s' unless number.zero?}"
  end
end