Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 74 lines (59 sloc) 2.42 KB
module Misuzilla::IronRuby
module TypableMap
include Misuzilla::Applications::TwitterIrcGateway::AddIns::TypableMap
@@commands = []
def self.setup
@@typablemap_proc = Session.AddInManager.GetAddIn(Misuzilla::Applications::TwitterIrcGateway::AddIns::TypableMapSupport.to_clr_type).TypableMapCommands
# スクリプトアンロード時にコマンドを削除する
Session.AddInManager.GetAddIn(Misuzilla::Applications::TwitterIrcGateway::AddIns::DLRIntegration::DLRIntegrationAddIn.to_clr_type).BeforeUnload do |sender, e|
@@commands.each do |command|
@@typablemap_proc.RemoveCommand(command)
end
end
end
def self.register(command, desc, &proc_cmd)
@@commands << command
@@typablemap_proc.AddCommand(command, desc, ProcessCommand.new{|p, msg, status, args|
proc_cmd.call(p, msg, status, args)
})
end
setup
end
end
def recursive_conversation(status, result_array)
if status != nil
result_array << status
rep_id = status.get_in_reply_to_status_id
if rep_id != ""
next_status = Session.twitter_service.get_post_by_status_id(rep_id)
recursive_conversation(next_status, result_array)
end
end
end
# TypableMap: c(conversation) コマンドを追加する
Misuzilla::IronRuby::TypableMap.register("c", "Show Conversation Command") do |p, msg, status, args|
Session.RunCheck(Misuzilla::Applications::TwitterIrcGateway::Procedure.new{
if status.get_in_reply_to_status_id == ""
outtext = "その発言は誰かへの返信ではないようです"
Session.send_server(Misuzilla::Net::Irc::NoticeMessage.new( msg.receiver,
outtext))
else
outtext = "#{status.user.screen_name}さんの会話:"
Session.send_server(Misuzilla::Net::Irc::NoticeMessage.new( msg.receiver,
outtext))
statuses = Array.new
recursive_conversation(status, statuses)
if statuses != nil
statuses.reverse.each do |stat|
time = stat.created_at.strftime("%H:%M:%S").to_s
outtext = " #{time}: #{stat.user.screen_name}: #{stat.text}"
Session.send_server(Misuzilla::Net::Irc::NoticeMessage.new( msg.receiver,
outtext))
end
end
end
}, System::Action[System::Exception].new{|ex|
Session.send_channel_message(msg.receiver, Server.server_nick, "メッセージ送信に失敗しました", false, false, true)
})
true # true を返すとハンドルしたことになりステータス更新処理は行われない
end