Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pingに対してpongを返すmikutterプラグイン
#-*- coding: utf-8 -*-
Plugin.create :ping_pong do
on_appear do |ms|
ms.each do |m|
if Time.now - m[:created] > 5
next
end
if m.message.to_s =~ /^@#{Service.primary.user.to_s} ping/
m.favorite
Service.primary.post :message => "@#{m.user.to_s} pong", :replyto => m.message
elsif m.message.to_s =~ /^@#{Service.primary.user.to_s} SYN/
m.favorite
Service.primary.post :message => "@#{m.user.to_s} ACK", :replyto => m.message
elsif m.message.to_s =~ /^@#{Service.primary.user.to_s} UUID/
m.favorite
Service.primary.post :message => "@#{m.user.to_s} #{`uuidgen`}", :replyto => m.message
elsif m.message.to_s =~ /^@#{Service.primary.user.to_s} 曜日/
m.favorite
Service.primary.post :message => "@#{m.user.to_s} #{`date +%A`}", :replyto => m.message
elsif m.message.to_s =~ /^@#{Service.primary.user.to_s} (時間|時刻)/
m.favorite
Service.primary.post :message => "@#{m.user.to_s} #{`date`}", :replyto => m.message
elsif m.message.to_s =~ /^@#{Service.primary.user.to_s} ([0-9]+)分後/
m.favorite
delay = $1.to_i
Reserver.new(Time.now + delay * 60) {
Service.primary.post :message => "@#{m.user.to_s} #{delay}分たったよ!", :replyto => m.message
}
elsif m.message.to_s =~ /^@#{Service.primary.user.to_s} ([0-9]+)秒後/
m.favorite
delay = $1.to_i
Reserver.new(Time.now + delay) {
Service.primary.post :message => "@#{m.user.to_s} #{delay}秒たったよ!", :replyto => m.message
}
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.