Skip to content

Instantly share code, notes, and snippets.

@yasulab
Last active December 18, 2015 10:59
Show Gist options
  • Save yasulab/5772846 to your computer and use it in GitHub Desktop.
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
#! /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
@yasulab
Copy link
Author

yasulab commented Jun 15, 2013

Ruby 2.0 に対応したり、設定ファイルを切り出したり、Gemfile で必要な gem をまとめて、次のリポジトリにまとめました!

なお、具体的な更新内容は次のとおりです。

  • Ruby 2.0 対応
  • Gemfile でパッケージ管理
  • 設定ファイルの切り出し
  • README.md の更新

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment