Sha256: 75e3dcdb75182860454fee1688d42034b7c2328156da3fe04c56fae9c20c01c0
Contents?: true
Size: 1.57 KB
Versions: 1
Compression:
Stored size: 1.57 KB
Contents
module CampfireBot module AbsenteeCamper autoload :Config, "absentee_camper/config" autoload :Logger, "absentee_camper/logger" autoload :NotificationManager, "absentee_camper/notification/notification_manager" module Notification autoload :EmailNotifier, "absentee_camper/notification/email_notifier" autoload :ProwlNotifier, "absentee_camper/notification/prowl_notifier" end class Plugin < CampfireBot::Plugin include Notification include Config on_message /@\w+/i, :role_call def initialize Logger.instance.log = bot.log end def role_call(msg) room = msg[:room] body = msg['body'] body.scan(/@\w+/).map(&:downcase).uniq.each do |mention| mentioned = mention[1..-1] if plugin_config['users'].keys.include? mentioned # If the user isn't in the room, fire off a notification unless room.users.map { |u| u['id'] }.include? user_id_from_config(mentioned) NotificationManager.new(room, plugin_config['users'][mentioned]).send_notifications body room.speak("[Notified #{mentioned}]") end end end end private def user_id_from_config(mentioned) if plugin_config['users'][mentioned].is_a? Hash plugin_config['users'][mentioned]['id'] else plugin_config['users'][mentioned] end end end module Helpers def room_uri(room) "https://#{root_config['site']}.campfirenow.com/room/#{room.id}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
campfire-bot-absentee-camper-0.1.0 | lib/campfire_bot/absentee_camper.rb |