[DRE-commits] [SCM] atig.git branch, master, updated. upstream/0.3.6-15-g76fd335
Youhei SASAKI
uwabami at gfd-dennou.org
Sat Feb 9 08:04:47 UTC 2013
The following commit has been merged in the master branch:
commit 9f2bd22c2fbe510307e3ef90c6778c4e9355cb45
Author: Youhei SASAKI <uwabami at gfd-dennou.org>
Date: Sun Jan 27 23:08:27 2013 +0900
Imported Upstream version 0.3.7
diff --git a/Gemfile.lock b/Gemfile.lock
index d97380b..6f6ae2c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- atig (0.3.6)
+ atig (0.3.7)
json
net-irc
oauth
@@ -12,19 +12,19 @@ GEM
remote: http://rubygems.org/
specs:
diff-lcs (1.1.3)
- json (1.7.3)
+ json (1.7.6)
net-irc (0.0.9)
- oauth (0.4.6)
- rake (0.9.2.2)
- rspec (2.10.0)
- rspec-core (~> 2.10.0)
- rspec-expectations (~> 2.10.0)
- rspec-mocks (~> 2.10.0)
- rspec-core (2.10.0)
- rspec-expectations (2.10.0)
+ oauth (0.4.7)
+ rake (10.0.3)
+ rspec (2.12.0)
+ rspec-core (~> 2.12.0)
+ rspec-expectations (~> 2.12.0)
+ rspec-mocks (~> 2.12.0)
+ rspec-core (2.12.2)
+ rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
- rspec-mocks (2.10.1)
- sqlite3 (1.3.6)
+ rspec-mocks (2.12.1)
+ sqlite3 (1.3.7)
PLATFORMS
ruby
diff --git a/README.mkdn b/README.mkdn
index 443542e..cc4234f 100644
--- a/README.mkdn
+++ b/README.mkdn
@@ -21,9 +21,9 @@ HOW TO USE
You type:
- $ cd atig
- $ ruby atig.rb -d
- I, [2010-04-05T07:22:07.861527 #62002] INFO -- : Host: localhost Port:16668
+ $ cd atig
+ $ bin/atig -d
+ I, [2010-04-05T07:22:07.861527 #62002] INFO -- : Host: localhost Port:16668
and access localhost:16668 by Irc client.
diff --git a/docs/changelog.rst b/docs/changelog.rst
index ab749c6..f10c718 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -1,6 +1,27 @@
更新履歴
==============
+v0.3.7(2013-01-27)
+------------------------------
+http://github.com/mzp/atig/tree/v0.3.7
+
+機能追加
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ - Twitter の Userstream に対応しました
+
+バグ修正
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ - Ruby 2.0.0(r38955) で動かない問題を直しました
+ - github の API の変更によりバージョンチェックが動かない問題を直しました
+
+ v0.3.6(2012-05-14)
+------------------------------
+http://github.com/mzp/atig/tree/v0.3.6
+
+機能変更
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ - Ruby 2.0.0 以降で iconv ライブラリが削除されることに伴う UTF7 サポートの終了
+
v0.3.5(2012-05-07)
------------------------------
http://github.com/mzp/atig/tree/v0.3.5
diff --git a/docs/options.rst b/docs/options.rst
index 1c405a3..022ce83 100644
--- a/docs/options.rst
+++ b/docs/options.rst
@@ -48,20 +48,20 @@ URL短縮関係
発言中の長いURLを自動で短縮します。どの短縮URLサービスを用いて短縮する
か、どの程度の長さのURLを短縮するか、などが設定できます。
-bitlify=\ ``size``
- ``size``\ 字以上のURLを http://bit.ly\ によって短縮します。
bitlify
|len|\ 字以上のURLを http://bit.ly\ によって短縮します。
-bitlify=\ ``api_key``:\ ``api_key``:\ ``size``
+bitlify=\ ``size``
+ ``size``\ 字以上のURLを http://bit.ly\ によって短縮します。
+bitlify=\ ``username``:\ ``api_key``
+ |len|\ 字以上のURLを http://bit.ly のAPIによって短縮します。
+bitlify=\ ``username``:\ ``api_key``:\ ``size``
``size``\ 字以上のURLを http://bit.ly のAPIによって短縮します。
APIを利用して短縮すると、ユーザページに短縮したURLが記録されたりします。
詳しくは、 http://bit.ly のSign up for bit.lyを読んでください。
-bitlify=\ ``api_key``:\ ``api_key``
- |len|\ 字以上のURLを http://bit.ly のAPIによって短縮します。
-unuify= \ ``size``
- ``size`` 字以上のURLを http://u.nu によって短縮します。
unuify
|len| 字以上のURLを http://u.nu によって短縮します。
+unuify= \ ``size``
+ ``size`` 字以上のURLを http://u.nu によって短縮します。
.. |len| replace:: 20
diff --git a/lib/atig/agent.rb b/lib/atig/agent.rb
index 24c89aa..8ee9dc8 100644
--- a/lib/atig/agent.rb
+++ b/lib/atig/agent.rb
@@ -7,3 +7,4 @@ require 'atig/agent/dm'
require 'atig/agent/timeline'
require 'atig/agent/clenup'
require 'atig/agent/user_stream'
+require 'atig/agent/noretweets'
diff --git a/lib/atig/agent/dm.rb b/lib/atig/agent/dm.rb
index 16e6442..8dbb21b 100644
--- a/lib/atig/agent/dm.rb
+++ b/lib/atig/agent/dm.rb
@@ -7,6 +7,7 @@ module Atig
include Util
def initialize(context, api, db)
+ return if context.opts.stream
@log = context.log
@api = api
@prev = nil
diff --git a/lib/atig/agent/mention.rb b/lib/atig/agent/mention.rb
index 84b0edf..391b3d3 100644
--- a/lib/atig/agent/mention.rb
+++ b/lib/atig/agent/mention.rb
@@ -4,7 +4,10 @@ require 'atig/agent/agent'
module Atig
module Agent
class Mention < Atig::Agent::Agent
- def initialize(context, api, db); super end
+ def initialize(context, api, db)
+ return if context.opts.stream
+ super
+ end
def interval; 180 end
def path; '/statuses/mentions' end
def source; :mention end
diff --git a/lib/atig/agent/noretweets.rb b/lib/atig/agent/noretweets.rb
new file mode 100644
index 0000000..ea50135
--- /dev/null
+++ b/lib/atig/agent/noretweets.rb
@@ -0,0 +1,24 @@
+# -*- mode:ruby; coding:utf-8 -*-
+
+require 'atig/util'
+
+module Atig
+ module Agent
+ class Noretweets
+ include Util
+
+ def initialize(context, api, db)
+ @opts = context.opts
+ @log = context.log
+ @db = db
+ log :info, "initialize"
+
+ api.repeat(3600){|t| update t }
+ end
+
+ def update(api)
+ @db.noretweets.clear.concat( api.get("friendships/no_retweet_ids") )
+ end
+ end
+ end
+end
diff --git a/lib/atig/agent/timeline.rb b/lib/atig/agent/timeline.rb
index a928f07..4f4ce88 100644
--- a/lib/atig/agent/timeline.rb
+++ b/lib/atig/agent/timeline.rb
@@ -4,7 +4,10 @@ require 'atig/agent/agent'
module Atig
module Agent
class Timeline < Atig::Agent::Agent
- def initialize(context, api, db); super end
+ def initialize(context, api, db)
+ return if context.opts.stream
+ super
+ end
def interval; 30 end
def path; '/statuses/home_timeline' end
def source; :timeline end
diff --git a/lib/atig/agent/user_stream.rb b/lib/atig/agent/user_stream.rb
index f96fb4a..e2b4866 100644
--- a/lib/atig/agent/user_stream.rb
+++ b/lib/atig/agent/user_stream.rb
@@ -18,10 +18,29 @@ module Atig
@api.stream do|t|
t.watch('user') do |status|
# @log.debug status.inspect
- if status and status.user
+ next if status.retweeted_status and db.noretweets.include?(status.user.id)
+ if status.direct_message
+ dm = status.direct_message
+ db.dms.transaction do|d|
+ d.add :status => dm, :user => dm.sender
+ end
+ elsif status and status.user
db.statuses.transaction do|d|
d.add :status => status, :user => status.user, :source => :user_stream
end
+ elsif status and status.event
+ case status.event
+ when 'list_member_added'
+ t.channel.notify "list member \00311added\017 : @#{status.target.screen_name} into #{status.target_object.full_name} [ http://twitter.com#{status.target_object.uri} ]"
+ when 'list_member_removed'
+ t.channel.notify "list member \00305removed\017 : @#{status.target.screen_name} from #{status.target_object.full_name} [ http://twitter.com#{status.target_object.uri} ]"
+ when 'follow'
+ t.channel.notify "#{status.source.screen_name} \00311follows\017 @#{status.target.screen_name}"
+ when 'favorite'
+ t.channel.notify "#{status.source.screen_name} \00311favorites\017 => @#{status.target_object.user.screen_name} : #{status.target_object.text}"
+ when 'unfavorite'
+ t.channel.notify "#{status.source.screen_name} \00305unfavorites\017 => @#{status.target_object.user.screen_name} : #{status.target_object.text}"
+ end
end
end
end
diff --git a/lib/atig/db/db.rb b/lib/atig/db/db.rb
index 74c31f9..d035292 100644
--- a/lib/atig/db/db.rb
+++ b/lib/atig/db/db.rb
@@ -13,7 +13,7 @@ module Atig
module Db
class Db
include Util
- attr_reader :followings, :statuses, :dms, :lists
+ attr_reader :followings, :statuses, :dms, :lists, :noretweets
attr_accessor :me
Path = ::Dir.tmpdir
VERSION = 4
@@ -26,6 +26,7 @@ module Atig
@statuses = Statuses.new dir('status')
@dms = Statuses.new dir('dm')
@lists = Lists.new dir('lists.%s')
+ @noretweets = Array.new
log :info, "initialize"
end
diff --git a/lib/atig/gateway.rb b/lib/atig/gateway.rb
index 8a12381..61e4221 100644
--- a/lib/atig/gateway.rb
+++ b/lib/atig/gateway.rb
@@ -9,6 +9,7 @@ Atig::Gateway::Session.agents = [
Atig::Agent::Timeline,
Atig::Agent::Cleanup,
Atig::Agent::UserStream,
+ Atig::Agent::Noretweets,
]
Atig::Gateway::Session.ifilters = [
diff --git a/lib/atig/gateway/session.rb b/lib/atig/gateway/session.rb
index 9dc5bec..ca5a664 100644
--- a/lib/atig/gateway/session.rb
+++ b/lib/atig/gateway/session.rb
@@ -96,7 +96,6 @@ END
@channels.each{|_, ch| ch.topic entry }
end
- protected
def on_message(m)
GC.start
@on_message.call(m) if @on_message
@@ -138,7 +137,13 @@ END
log :debug, "initialize Twitter"
twitter = Twitter.new context, oauth.access
search = SearchTwitter.new context
- stream = Stream.new context, @nick, at pass if @opts.stream
+ if @opts.stream
+ unless @channels.key?("##{@nick}")
+ ch = channel("##{@nick}")
+ ch.join_me
+ end
+ end
+ stream = Stream.new context, @channels["##{@nick}"], oauth.access if @opts.stream
@api = Scheduler.new context, twitter, search, stream
log :debug, "initialize filter"
@@ -169,34 +174,10 @@ END
end
end
- def run_new(klasses,*args)
- (klasses || []).map do|klass|
- if klass.respond_to?(:new)
- klass.new(*args)
- else
- klass
- end
- end
- end
-
def on_disconnected
(@thread_group.list - [Thread.current]).each {|t| t.kill }
end
- CONFIG_FILE = File.expand_path("~/.atig/oauth")
- def save_config
- FileUtils.mkdir_p File.dirname(CONFIG_FILE)
- File.open(CONFIG_FILE, "w") {|io|
- YAML.dump(OAuth.dump,io)
- }
- FileUtils.chmod 0600, CONFIG_FILE
- end
-
- def load_config
- FileUtils.mkdir_p File.dirname(CONFIG_FILE)
- OAuth.load(YAML.load_file(CONFIG_FILE)) rescue nil
- end
-
def on_privmsg(m)
target, mesg = *m.params
m.ctcps.each {|ctcp| on_ctcp(target, ctcp) } if m.ctcp?
@@ -314,6 +295,32 @@ END
post server_name, RPL_ENDOFWHO, @nick, channel
end
+ protected
+
+ def run_new(klasses,*args)
+ (klasses || []).map do|klass|
+ if klass.respond_to?(:new)
+ klass.new(*args)
+ else
+ klass
+ end
+ end
+ end
+
+ CONFIG_FILE = File.expand_path("~/.atig/oauth")
+ def save_config
+ FileUtils.mkdir_p File.dirname(CONFIG_FILE)
+ File.open(CONFIG_FILE, "w") {|io|
+ YAML.dump(OAuth.dump,io)
+ }
+ FileUtils.chmod 0600, CONFIG_FILE
+ end
+
+ def load_config
+ FileUtils.mkdir_p File.dirname(CONFIG_FILE)
+ OAuth.load(YAML.load_file(CONFIG_FILE)) rescue nil
+ end
+
def available_user_modes
"o"
end
diff --git a/lib/atig/oauth.rb b/lib/atig/oauth.rb
index cd7c2d0..f23f136 100644
--- a/lib/atig/oauth.rb
+++ b/lib/atig/oauth.rb
@@ -20,6 +20,7 @@ module Atig
end
attr_reader :access
+ attr_reader :oauth
def initialize(context, nick)
uri = URI(context.opts.api_base)
site = "http://#{uri.host}"
diff --git a/lib/atig/option.rb b/lib/atig/option.rb
index 9c9897a..05c5efc 100644
--- a/lib/atig/option.rb
+++ b/lib/atig/option.rb
@@ -30,7 +30,7 @@ module Atig
end
default_value :api_base, 'https://api.twitter.com/1/'
- default_value :stream_api_base, 'http://chirpstream.twitter.com/2b/'
+ default_value :stream_api_base, 'https://userstream.twitter.com/2/'
default_value :search_api_base, 'http://search.twitter.com/'
def initialize(table)
diff --git a/lib/atig/stream.rb b/lib/atig/stream.rb
index 5f1360d..ff846bf 100644
--- a/lib/atig/stream.rb
+++ b/lib/atig/stream.rb
@@ -12,12 +12,14 @@ module Atig
class Stream
include Util
+ attr_reader :channel
+
class APIFailed < StandardError; end
- def initialize(context, user, password)
+ def initialize(context, channel, access)
@log = context.log
@opts = context.opts
- @user = user
- @password = password
+ @channel = channel
+ @access = access
end
def watch(path, query={}, &f)
@@ -30,32 +32,31 @@ module Atig
@log.debug [uri.to_s]
- Net::HTTP.start(uri.host, uri.port) do |http|
- request = Net::HTTP::Post.new uri.request_uri
- request.basic_auth @user, @password
-
- http.request(request) do |response|
- unless response.code == '200' then
- raise APIFailed,"#{response.code} #{response.message}"
- end
+ http = Net::HTTP.new(uri.host, uri.port)
+ http.use_ssl = true
+ request = Net::HTTP::Get.new(uri.request_uri)
+ request.oauth!(http, @access.consumer, @access)
+ http.request(request) do |response|
+ unless response.code == '200' then
+ raise APIFailed,"#{response.code} #{response.message}"
+ end
- begin
- buffer = ''
- response.read_body do |chunk|
- next if chunk.chomp.empty?
- buffer << chunk.to_s
+ begin
+ buffer = ''
+ response.read_body do |chunk|
+ next if chunk.chomp.empty?
+ buffer << chunk.to_s
- if buffer =~ /\A(.*)\n/ then
- text = $1
- unless text.strip.empty?
- f.call TwitterStruct.make(JSON.parse(text))
- end
- buffer = ''
+ if buffer =~ /\A(.*)\n/ then
+ text = $1
+ unless text.strip.empty?
+ f.call TwitterStruct.make(JSON.parse(text))
end
+ buffer = ''
end
- rescue => e
- raise APIFailed,e.to_s
end
+ rescue => e
+ raise APIFailed,e.to_s
end
end
end
diff --git a/lib/atig/update_checker.rb b/lib/atig/update_checker.rb
index 9e87121..1c876fa 100644
--- a/lib/atig/update_checker.rb
+++ b/lib/atig/update_checker.rb
@@ -3,10 +3,10 @@
module Atig
module UpdateChecker
def commits
- uri = URI("http://github.com/api/v1/json/mzp/atig/commits/master")
+ uri = URI("https://api.github.com/repos/mzp/atig/commits")
http = Atig::Http.new
res = http.http(uri).request http.req(:get, uri)
- JSON.parse(res.body)['commits']
+ JSON.parse(res.body)
end
def server_version
@@ -29,18 +29,18 @@ module Atig
[]
else
cs = commits
- latest = cs.first['id'][/^[0-9a-z]{40}$/]
+ latest = cs.first['sha'][/^[0-9a-z]{40}$/]
raise "github API changed?" unless latest
if local_repos?(latest) then
[]
else
- current = cs.map {|i| i['id'] }.index(server_version)
+ current = cs.map {|i| i['sha'] }.index(server_version)
if current then
cs[0...current]
else
cs
- end.map {|i| i['message'] }
+ end.map {|i| i['commit']['message'] }
end
end
rescue Errno::ECONNREFUSED, Timeout::Error => e
diff --git a/lib/atig/version.rb b/lib/atig/version.rb
index 3370dfc..7ec4d6d 100644
--- a/lib/atig/version.rb
+++ b/lib/atig/version.rb
@@ -1,3 +1,3 @@
module Atig
- VERSION = "0.3.6"
+ VERSION = "0.3.7"
end
diff --git a/metadata.yml b/metadata.yml
index cd3e5ce..08d6781 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,7 +1,7 @@
--- !ruby/object:Gem::Specification
name: atig
version: !ruby/object:Gem::Version
- version: 0.3.6
+ version: 0.3.7
prerelease:
platform: ruby
authors:
@@ -9,7 +9,7 @@ authors:
autorequire:
bindir: bin
cert_chain: []
-date: 2012-05-14 00:00:00.000000000 Z
+date: 2013-01-27 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: sqlite3
@@ -160,6 +160,7 @@ files:
- lib/atig/agent/list.rb
- lib/atig/agent/list_status.rb
- lib/atig/agent/mention.rb
+- lib/atig/agent/noretweets.rb
- lib/atig/agent/other_list.rb
- lib/atig/agent/own_list.rb
- lib/atig/agent/stream_follow.rb
@@ -299,18 +300,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
- - ! '>='
- !ruby/object:Gem::Version
version: '0'
- segments:
- - 0
- hash: 2969950395206530754
required_rubygems_version: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: '0'
- segments:
- - 0
- hash: 2969950395206530754
requirements: []
rubyforge_project:
rubygems_version: 1.8.24
@@ -360,3 +355,4 @@ test_files:
- spec/sized_hash_spec.rb
- spec/spec_helper.rb
- spec/update_checker_spec.rb
+has_rdoc:
diff --git a/spec/update_checker_spec.rb b/spec/update_checker_spec.rb
index fd3c18b..7d35183 100644
--- a/spec/update_checker_spec.rb
+++ b/spec/update_checker_spec.rb
@@ -9,7 +9,7 @@ describe Atig::UpdateChecker,'when use git version' do
end
def commit(c, mesg)
- {'id' => rev(c), 'message' => mesg}
+ {'sha' => rev(c), 'commit' => {'message' => mesg}}
end
before do
--
atig.git
More information about the Pkg-ruby-extras-commits
mailing list