net-irc 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ 2009-02-19 SATOH Hiroh <cho45@lowreal.net>
2
+
3
+ * [bug]:
4
+ Fixed net/irc.rb permission.
5
+ * Released 0.0.7
6
+
1
7
  2009-02-01 SATOH Hiroh <cho45@lowreal.net>
2
8
 
3
9
  * [bug]:
@@ -92,7 +92,7 @@ class HatenaStarStream < Net::IRC::Server::Session
92
92
  @log.info "getting report..."
93
93
  @ua.get("http://s.hatena.ne.jp/#{@real}/report")
94
94
  entries = @ua.page.root.search("#main span.entry-title a").map {|a|
95
- a[:href]
95
+ a['href']
96
96
  }
97
97
 
98
98
  @log.info "getting stars... #{entries.length}"
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # vim:encoding=utf-8:
2
3
  =begin
3
4
  # hig.rb
4
5
 
@@ -521,17 +521,17 @@ if __FILE__ == $0
521
521
  opts[:logger].level = opts[:debug] ? Logger::DEBUG : Logger::INFO
522
522
 
523
523
  def daemonize(foreground=false)
524
- trap("SIGINT") { exit! 0 }
525
- trap("SIGTERM") { exit! 0 }
526
- trap("SIGHUP") { exit! 0 }
524
+ [:INT, :TERM, :HUP].each do |sig|
525
+ Signal.trap sig, "EXIT"
526
+ end
527
527
  return yield if $DEBUG || foreground
528
528
  Process.fork do
529
529
  Process.setsid
530
530
  Dir.chdir "/"
531
531
  File.open("/dev/null") {|f|
532
532
  STDIN.reopen f
533
- STDOUT.reopen f, 'w'
534
- STDERR.reopen f, 'w'
533
+ STDOUT.reopen f, "w"
534
+ STDERR.reopen f, "w"
535
535
  }
536
536
  yield
537
537
  end
@@ -275,7 +275,7 @@ module Lingr
275
275
 
276
276
  def post(url, params)
277
277
  if !params.find {|p| p[1].is_a?(Hash)}
278
- params = params.inject({}){|hash,(k,v)| hash[k.to_s] = v; hash}
278
+ params = params.inject({}){|hash,(k,v)| hash[k.to_s] = v; hash}
279
279
  parse_result Net::HTTP.post_form(URI.parse(url), params)
280
280
  else
281
281
  boundary = 'lingr-api-client' + (0x1000000 + rand(0x1000000).to_s(16))
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # vim:fileencoding=utf-8:
3
+ # -*- coding: utf-8 -*-
2
4
  =begin
3
5
 
4
6
  # tig.rb
@@ -115,7 +117,7 @@ Force SSL for API.
115
117
 
116
118
  ### in (location)
117
119
 
118
- /me in Tokyo, Japan
120
+ /me in Sugamo, Tokyo, Japan
119
121
 
120
122
  ### reply (re)
121
123
 
@@ -125,6 +127,14 @@ Force SSL for API.
125
127
 
126
128
  /me utf7
127
129
 
130
+ ### name
131
+
132
+ /me name My Name
133
+
134
+ ### description (desc)
135
+
136
+ /me description blah, blah...
137
+
128
138
  ## License
129
139
 
130
140
  Ruby's by cho45
@@ -230,7 +240,6 @@ class TwitterIrcGateway < Net::IRC::Server::Session
230
240
  @check_rate_limit_thread = Thread.start do
231
241
  loop do
232
242
  begin
233
- check_downtime
234
243
  check_rate_limit
235
244
  rescue ApiFailed => e
236
245
  @log.error e.inspect
@@ -323,7 +332,7 @@ class TwitterIrcGateway < Net::IRC::Server::Session
323
332
  retry_count = 3
324
333
  ret = nil
325
334
  target, message = *m.params
326
- message = Iconv.iconv("UTF-7", "UTF-8", message).join if @utf7
335
+ message = Iconv.iconv("UTF-7", "UTF-8", message).join.force_encoding("ASCII-8BIT") if @utf7
327
336
  begin
328
337
  if target =~ /^#/
329
338
  if @opts.key?("alwaysim") && @im && @im.connected? # in jabber mode, using jabber post
@@ -612,7 +621,7 @@ class TwitterIrcGateway < Net::IRC::Server::Session
612
621
 
613
622
  begin
614
623
  require "iconv"
615
- mesg = mesg.sub(/^.+ > |^.+/) {|str| Iconv.iconv("UTF-8", "UTF-7", str).join }
624
+ mesg = mesg.sub(/^.+ > |^.+/) {|str| Iconv.iconv("UTF-8", "UTF-7", str).join }
616
625
  mesg = "[utf7]: #{mesg}" if body =~ /[^a-z0-9\s]/i
617
626
  rescue LoadError
618
627
  rescue Iconv::IllegalSequence
@@ -698,21 +707,6 @@ class TwitterIrcGateway < Net::IRC::Server::Session
698
707
  # rate_limit["reset_time_in_seconds"] - Time.now.to_i
699
708
  end
700
709
 
701
- def check_downtime
702
- @prev_downtime ||= nil
703
- schedule = api("help/downtime_schedule", {}, { :suppress_errors => true })["error"]
704
- if @prev_downtime != schedule && @prev_downtime = schedule
705
- msg = schedule.gsub(%r{[\r\n]|<style(?:\s[^>]*)?>.*?</style\s*>}m, "")
706
- uris = URI.extract(msg)
707
- uris.each do |uri|
708
- msg << " #{uri}"
709
- end
710
- msg.gsub!(/<[^>]+>/, "")
711
- log "\002\037#{msg}\017"
712
- # TODO: sleeping for the downtime
713
- end
714
- end
715
-
716
710
  def freq(ratio)
717
711
  max = (@opts["maxlimit"] || 100).to_i
718
712
  limit = @hourly_limit < max ? @hourly_limit : max
@@ -869,7 +863,7 @@ class TwitterIrcGateway < Net::IRC::Server::Session
869
863
  end
870
864
 
871
865
  def log(str)
872
- str.gsub!(/\r?\n|\r/, " ")
866
+ str.gsub!(/\r\n|[\r\n]/, " ")
873
867
  post server_name, NOTICE, main_channel, str
874
868
  end
875
869
 
@@ -992,18 +986,16 @@ if __FILE__ == $0
992
986
  opts[:logger].level = opts[:debug] ? Logger::DEBUG : Logger::INFO
993
987
 
994
988
  # def daemonize(foreground = false)
995
- # trap("SIGINT") { exit! 0 }
996
- # trap("SIGTERM") { exit! 0 }
997
- # trap("SIGHUP") { exit! 0 }
989
+ # [:INT, :TERM, :HUP].each do |sig|
990
+ # Signal.trap sig, "EXIT"
991
+ # end
998
992
  # return yield if $DEBUG || foreground
999
993
  # Process.fork do
1000
994
  # Process.setsid
1001
995
  # Dir.chdir "/"
1002
- # File.open("/dev/null") {|f|
1003
- # STDIN.reopen f
1004
- # STDOUT.reopen f
1005
- # STDERR.reopen f
1006
- # }
996
+ # STDIN.reopen "/dev/null"
997
+ # STDOUT.reopen "/dev/null", "a"
998
+ # STDERR.reopen STDOUT
1007
999
  # yield
1008
1000
  # end
1009
1001
  # exit! 0
@@ -1013,7 +1005,3 @@ if __FILE__ == $0
1013
1005
  Net::IRC::Server.new(opts[:host], opts[:port], TwitterIrcGateway, opts).start
1014
1006
  # end
1015
1007
  end
1016
-
1017
- # Local Variables:
1018
- # coding: utf-8
1019
- # End:
@@ -259,7 +259,7 @@ class WassrIrcGateway < Net::IRC::Server::Session
259
259
  if target =~ /^#(.+)/
260
260
  channel = Regexp.last_match[1]
261
261
  reply = message[/\s+>(.+)$/, 1]
262
- message = Iconv.iconv("UTF-7", "UTF-8", message).join if @utf7
262
+ message = Iconv.iconv("UTF-7", "UTF-8", message).join.force_encoding("ASCII-8BIT") if @utf7
263
263
  if !reply && @opts.key?("alwaysim") && @im && @im.connected? # in jabber mode, using jabber post
264
264
  message = "##{channel} #{message}" unless "##{channel}" == main_channel
265
265
  ret = @im.deliver(jabber_bot_id, message)
@@ -9,7 +9,7 @@ require "monitor"
9
9
  module Net; end
10
10
 
11
11
  module Net::IRC
12
- VERSION = "0.0.6"
12
+ VERSION = "0.0.7"
13
13
  class IRCException < StandardError; end
14
14
 
15
15
  require "net/irc/constants"
@@ -82,7 +82,7 @@ class Net::IRC::Message
82
82
  # If the message is CTCP, return true.
83
83
  def ctcp?
84
84
  message = @params[1]
85
- message[0] == "\01"[0] && message[message.length-1] == "\01"[0]
85
+ message[0] == ?\01 && message[message.length-1] == ?\01
86
86
  end
87
87
 
88
88
  def inspect
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- # ENCODING=ASCII-8BIT
3
- # :vim:encoding=utf-8:
4
- # ↑ どうするのが正解?
2
+ # coding: ASCII-8BIT
3
+ # :vim:fileencoding=utf-8:
5
4
 
6
5
  $LOAD_PATH << "lib"
7
6
  $LOAD_PATH << "../lib"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-irc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - cho45
@@ -9,7 +9,7 @@ autorequire: ""
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-01 00:00:00 +09:00
12
+ date: 2009-02-19 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15