Last active
December 18, 2015 10:59
-
-
Save yasulab/5772846 to your computer and use it in GitHub Desktop.
Simple Comment Viewer for ScreenX TV ( http://screenx.tv/ ) なお、投稿にも対応した本格的コメントビューワーはこちらです: https://github.com/aki-017/screenx-commentviewer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
### Settings | |
# 1. To use SocketIO, type the following: | |
# $ gem install socketio-client | |
require "SocketIO" | |
# 2. Tune to your channel | |
# Ex. http://screenx.tv/#{channel} | |
channel = 'demo' | |
# 3. Turn on `saykana` if you'd like to hear Japanese comments by voice. | |
saykana = false | |
root_url = "http://screenx.tv" | |
uri = URI(root_url) | |
uri.port = 8800 | |
puts "ScreenX TV Comment Viewer" | |
puts "Channel: #{root_url}/#{channel}" | |
puts "" | |
name = '' | |
msg = '' | |
client = SocketIO.connect(uri) do | |
before_start do | |
on_message {|message| | |
puts message | |
} | |
on_event('chat'){ |data| | |
name = data.first['name'] | |
msg = data.first['message'] | |
puts "@#{name}: #{msg}" | |
`saykana -s 100 #{msg}` if saykana | |
} | |
on_event('viewer'){ |data| | |
puts "Viewer: #{data.first['viewer']}" | |
} | |
on_disconnect {puts "I GOT A DISCONNECT"} | |
end | |
after_start do | |
emit("init", {channel: channel}) | |
end | |
end | |
loop do | |
sleep 10 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ruby 2.0 に対応したり、設定ファイルを切り出したり、Gemfile で必要な gem をまとめて、次のリポジトリにまとめました!
なお、具体的な更新内容は次のとおりです。