Skip to content

Instantly share code, notes, and snippets.

@okkez
Created March 26, 2010 14:43
Show Gist options
  • Save okkez/344959 to your computer and use it in GitHub Desktop.
Save okkez/344959 to your computer and use it in GitHub Desktop.
diff --git a/lib/plugins/defaults/retweet.rb b/lib/plugins/defaults/retweet.rb
index b2db68d..e07d152 100644
--- a/lib/plugins/defaults/retweet.rb
+++ b/lib/plugins/defaults/retweet.rb
@@ -33,6 +33,7 @@ module Termtter::Client
comment += ' ' unless comment.nil?
rt_or_qt = (config.plugins.retweet.quotetweet and comment) ? 'QT' : 'RT'
text = ERB.new(config.plugins.retweet.format).result(binding)
+ get_hooks(:modify_status_for_retweet).each{|hook| text = hook.call(text) || '' }
Termtter::API.twitter.update(text)
puts "=> #{text}"
end
diff --git a/lib/plugins/defaults/standard_commands.rb b/lib/plugins/defaults/standard_commands.rb
index d53cb5f..46d29b6 100644
--- a/lib/plugins/defaults/standard_commands.rb
+++ b/lib/plugins/defaults/standard_commands.rb
@@ -474,6 +474,7 @@ module Termtter::Client
class << self
def update_with_user_and_id(text, username, id)
text = "@#{username} #{text}"
+ get_hooks(:modify_status_for_reply).each{|hook| text = hook.call(text) }
result = Termtter::API.twitter.update(text, {'in_reply_to_status_id' => id })
puts "replied => #{result.text}"
end
diff --git a/lib/plugins/sama.rb b/lib/plugins/sama.rb
new file mode 100644
index 0000000..459c718
--- /dev/null
+++ b/lib/plugins/sama.rb
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+
+config.plugins.sama.set_default(:suffix, " 様")
+
+options = {
+ :name => :sama,
+ :points => [:modify_arg_for_update, :modify_status_for_retweet, :modify_status_for_reply],
+ :exec_proc => lambda{|*args|
+ text = case args.size
+ when 1 then args.shift
+ when 2 then args.last
+ else raise "must not happen!"
+ end
+ suffix = config.plugins.sama.suffix
+ text.gsub(/(?>(@\w+))(?!#{suffix})?/){ $1 + suffix }
+ }
+}
+
+Termtter::Client.register_hook(options)
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment