Class: Cinch::Plugins::JoinNotice

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/cinch/plugins/joinnotice.rb

Instance Method Summary collapse

Instance Method Details

#get_channel_greeting(channel) ⇒ Object


12
13
14
# File 'lib/cinch/plugins/joinnotice.rb', line 12

def get_channel_greeting(channel)
  open([config[:greetings], channel.downcase, config[:filext]].join, &:read) rescue nil
end

#listen(m) ⇒ Object


18
19
20
21
22
23
# File 'lib/cinch/plugins/joinnotice.rb', line 18

def listen(m)
  return if m.user == @bot
  greeting = get_channel_greeting(m.channel.name)
  return if greeting.blank?
  m.user.notice greeting.split($/).delete_if{|e| e.match(/^\/\//)}.map {|e| "[#{m.channel.name}] #{e.to_s}"}.join($/)
end