日記はScrapboxに移動しました。

(CANCELLED) IRCへの投稿文字列を色付けするライブラリを書いた

(追記あり)

IRCへの通知をいい感じにするに際して、色付けしたりするとよりよいだろうなという感じなわけですが、Rubyでそこらへんいい感じにしてくれるモジュールが見当たらなかったので、id:hirose31さんのString::IRCを参考にして作ってみました。

こんな感じになります。

f:id:antipop:20120605021513p:plain

詳しい使い方などは、上記GitHubのREADMEを参照のこと。

つか、これ、rake releaseすると、以下のようなエラーが出てrubygemsに上げられないのですが、なんでなんでしょうか……。

$ be rake release
string-irc 0.0.1 built to pkg/string-irc-0.0.1.gem
Tagged v0.0.1Pushed git commits and tags
Untagged v0.0.1 due to error
rake aborted!
Pushing gem to https://rubygems.org...
You do not have permission to push to this gem.

ちなみに、Cinchを使うと以下のような簡単なコードで適当にボット作れるので、いいですね。

require 'cinch'
require 'string/irc/core_ext/string'
bot = Cinch::Bot.new do
configure do |c|
c.server = "irc.freenode.org"
c.channels = ["#antipop"]
end
on :message, /hello/ do |m|
m.reply "#{'Hello'.irc_colorize(:white, :red)}, #{m.user.nick}"
end
end
bot.start

追記

permissionがどうちゃらいう件、rubygemsを検索してなかったので作ったつもりだったのだが、

というわけで、既にあったせいだった。うえに、作者は同僚の@banyanなのであったw

というわけで、↑を使いましょう!!1

2 comments

Leave a Reply

Your email address will not be published. Required fields are marked *