root/lang/ruby/maraigue-twitter/nobotter/nobotter_web.rb

Revision 31502, 1.0 kB (checked in by maraigue, 3 years ago)

first commitment of maraigue-twitter

Line 
1#!/usr/bin/env ruby
2# -*- coding: utf-8 -*-
3require "rubygems"
4require "json"
5require "open-uri"
6
7require "twbot"
8
9class NobotterWeb < TwBot
10        def load_data
11                status = YAML.load_file("config.yml")
12                user_list = ""
13                us_list = ""
14                ds_list = ""
15                status["history"].each_value do |user|
16                        user_list += user['name'] + '+'
17                        us_list += user['upstair'].to_s + '+'
18                        ds_list += user['downstair'].to_s + '+'
19                end
20               
21                params = "registkey=#{@config['reg_key']}&name_user=#{user_list}&us=#{us_list}&ds=#{ds_list}"
22                STDERR.puts params
23               
24                buf = nil
25                open("http://hhiro.net/nobotter/status.cgi?#{params}") do |file|
26                        buf = file.read
27                end
28       
29                case buf
30                when /Nobotter-OK/
31                        @logmsg = "(Chart registration: OK)"
32                when /Nobotter-NG/
33                        @logmsg = "(Chart registration: NG)"
34                else
35                        @logmsg = "(Chart registration: Failed)"
36                end
37               
38                [] # return value
39        end
40end
41
42SELFDIR = File.dirname(__FILE__)
43NobotterWeb.new ARGV[0], "#{SELFDIR}/config-web.yml", "#{SELFDIR}/error-web.log"
44
Note: See TracBrowser for help on using the browser.