Skip to content

Instantly share code, notes, and snippets.

@firstspring1845
Created April 29, 2014 07:25
Show Gist options
  • Save firstspring1845/11392885 to your computer and use it in GitHub Desktop.
Save firstspring1845/11392885 to your computer and use it in GitHub Desktop.
某氏の動かしてるbotの機能をmikutterプラグイン化したものです、anime_iconとリプライを貰うと用意したアイコンにランダムで変更します。 プラグインと同じディレクトリにiconディレクトリを作成しその中に入れてください
# -*- coding: utf-8 -*-
Plugin.create :mikutter_anime_icon do
require 'base64'
on_mention do |s,ms|
ms.each do |m|
if Time.now - m.message[:created] < 5 then
if m.message.to_s.split[1] == 'anime_icon' then
dir = File.expand_path(File.join(File.dirname(__FILE__), "icon"))
subdir = ['.','..']
icons = Dir::entries(dir).select{|p| !subdir.include?(p)}
icon = dir + '/' + icons.sample
(Service.primary.twitter/'account/update_profile_image').json(:image => Base64.encode64(File.binread(icon))).next do |d|
Service.primary.post(:message => "@#{m.user.idname} アイコンを変更しました。", :replyto => m.message)
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment