diff --git a/.env.example b/.env.example index c09d40b..99add8f 100644 --- a/.env.example +++ b/.env.example @@ -39,6 +39,8 @@ LIVE_MODE=true # Digital Ocean Droplet Admin # DO_API_KEY=xxxxxxxxx +SILENT_MODE=false + ############################################################ # SOCKET_KEY_ID # Default: false, websocket cx will be ID'd by request.ip diff --git a/extensions.rb b/extensions.rb new file mode 100644 index 0000000..4cf1bd1 --- /dev/null +++ b/extensions.rb @@ -0,0 +1,39 @@ +require 'cinchize' + +SILENT_MODE="SILENT_MODE" + +class Cinch::User + def send(text) + if ENV[SILENT_MODE].downcase == 'true' + puts "%s: Private message to %s = %s" % [SILENT_MODE, nick, text] + else + super text + end + end +end + +class Cinch::Message + def reply(text) + if ENV[SILENT_MODE].downcase == 'true' + puts "%s: Reply to %s = %s" % [SILENT_MODE, user.nick, text] + else + text = text.to_s + if @channel && prefix + text = text.split("\n").map {|l| "#{user.nick}: #{l}"}.join("\n") + end + reply_target.send(text) + end + end +end + +class Cinch::Message + def action_reply(text) + if ENV[SILENT_MODE].downcase == 'true' + puts "%s: Action reply to %s = %s" % [SILENT_MODE, user.nick, text] + else + text = text.to_s + reply_target.action(text) + end + end +end + diff --git a/showbot_irc.rb b/showbot_irc.rb index e50d510..b61dc88 100644 --- a/showbot_irc.rb +++ b/showbot_irc.rb @@ -2,6 +2,7 @@ require 'optparse' require 'cinchize' +require './extensions.rb' require 'droplet_kit' require 'auth/admin_plugin'