Commit b8270bd3 authored by Youhei SASAKI's avatar Youhei SASAKI

Imported Upstream version 0.4.5

parent b9a4bedc
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1.0
script: bundle exec rake spec
source :rubygems
source 'https://rubygems.org'
gemspec
PATH
remote: .
specs:
atig (0.3.6)
json
atig (0.4.4)
net-irc
oauth
rake
sqlite3 (>= 1.3.2)
twitter-text (~> 1.7.0)
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
diff-lcs (1.1.3)
json (1.7.3)
coveralls (0.7.0)
multi_json (~> 1.3)
rest-client
simplecov (>= 0.7)
term-ansicolor
thor
diff-lcs (1.2.5)
docile (1.1.2)
mime-types (2.0)
multi_json (1.8.4)
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)
diff-lcs (~> 1.1.3)
rspec-mocks (2.10.1)
sqlite3 (1.3.6)
oauth (0.4.7)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.4)
simplecov (0.8.2)
docile (~> 1.1.0)
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
sqlite3 (1.3.8)
term-ansicolor (1.2.2)
tins (~> 0.8)
thor (0.18.1)
tins (0.13.1)
twitter-text (1.7.0)
unf (~> 0.1.0)
unf (0.1.3)
unf_ext
unf_ext (0.0.6)
PLATFORMS
ruby
DEPENDENCIES
atig!
bundler
coveralls
rspec
......@@ -10,9 +10,8 @@ Atig.rb is forked from cho45's tig.rb. We improve some features of tig.rb.
PREREQUISITES
-------------
* Ruby 1.8 or 1.9
* Ruby 1.9.3 or later
* sqlite3-ruby
* json(when use Ruby 1.8)
* rspec(for unit test)
* rake(for unit test)
......@@ -21,9 +20,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.
......
# -*- mode:ruby -*-
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rspec/core/rake_task'
......@@ -10,11 +9,18 @@ CLEAN.include(
)
CLOBBER.include(
"pkg"
"pkg",
"coverage"
)
RSpec::Core::RakeTask.new do |t|
t.pattern = 'spec/**/*_spec.rb'
end
desc "building document with sphinx"
task :docs do
build_dir = "docs/_build"
`LC_CTYPE=C sphinx-build -b html -d #{build_dir}/doctrees -D latex_paper_size=a4 docs #{build_dir}/html`
end
task :default => [:spec, :clean]
......@@ -2,8 +2,8 @@
require File.expand_path('../lib/atig/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["SHIBATA Hiroshi"]
gem.email = ["shibata.hiroshi@gmail.com"]
gem.authors = ["MIZUNO Hiroki", "SHIBATA Hiroshi", ]
gem.email = ["mzp@ocaml.jp", "shibata.hiroshi@gmail.com"]
gem.description = %q{Atig.rb is Twitter Irc Gateway.}
gem.summary = %q{Atig.rb is forked from cho45's tig.rb. We improve some features of tig.rb.}
gem.homepage = "https://github.com/mzp/atig"
......@@ -15,11 +15,14 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]
gem.version = Atig::VERSION
gem.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
gem.add_dependency 'sqlite3', ['>= 1.3.2']
gem.add_dependency 'net-irc', ['>= 0']
gem.add_dependency 'oauth', ['>= 0']
gem.add_dependency 'twitter-text', ['~> 1.7.0']
gem.add_dependency 'rake', ['>= 0'] unless defined? Rake
gem.add_dependency 'json', ['>= 0'] unless defined? JSON
gem.add_development_dependency 'rspec', ['>= 0']
gem.add_development_dependency 'bundler'
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'coveralls'
end
# OMakefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_a4) $(SPHINXOPTS) .
SRCS[] =
index
config
options
tiarra
commandline_options
commands
quickstart
feature
irc
changelog
tig
.PHONY : clean
.DEFAULT: $(addsuffix .rst, $(SRCS))
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
clean:
rm -rf $(BUILDDIR)/html/* *~
\ No newline at end of file
########################################################################
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this file, to deal in the File without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the File, and to permit persons to whom the
# File is furnished to do so, subject to the following condition:
#
# THE FILE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE FILE OR
# THE USE OR OTHER DEALINGS IN THE FILE.
########################################################################
# The standard OMakeroot file.
# You will not normally need to modify this file.
# By default, your changes should be placed in the
# OMakefile in this directory.
#
# If you decide to modify this file, note that it uses exactly
# the same syntax as the OMakefile.
#
#
# Include the standard installed configuration files.
# Any of these can be deleted if you are not using them,
# but you probably want to keep the Common file.
#
open build/C
open build/OCaml
open build/LaTeX
#
# The command-line variables are defined *after* the
# standard configuration has been loaded.
#
DefineCommandVars()
#
# Include the OMakefile in this directory.
#
.SUBDIRS: .
更新履歴
==============
v0.4.4(2013-12-29)
------------------------------
http://github.com/mzp/atig/tree/v0.4.4
機能変更
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- サポート対象を Ruby 1.9.3 以降にしました
- follower 取得時の1回の取得数を100件に拡張しました
v0.4.3(2013-10-18)
------------------------------
http://github.com/mzp/atig/tree/v0.4.3
不具合修正
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 短縮 URL の展開が動かない問題を修正しました
v0.4.2(2013-10-13)
------------------------------
http://github.com/mzp/atig/tree/v0.4.2
機能変更
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- タイムラインの取得間隔を 1 分にしました
v0.4.1(2013-08-02)
------------------------------
http://github.com/mzp/atig/tree/v0.4.1
不具合修正
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- '&' が置換されない問題を修正しました
- reply が取得できない不具合を修正しました
- list の追加・削除 API が 1.0 のままだった問題を修正しました
v0.4.0(2013-06-12)
------------------------------
http://github.com/mzp/atig/tree/v0.4.0
機能変更
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Twitter API 1.1に対応しました
v0.3.12(2013-04-02)
------------------------------
http://github.com/mzp/atig/tree/v0.3.12
機能追加
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- v0.3.10-11 で --tmpdir オプションが動作していない不具合を直しました
v0.3.11(2013-04-02)
------------------------------
http://github.com/mzp/atig/tree/v0.3.11
機能追加
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- v0.3.10 で起動できない不具合を直しました
v0.3.10(2013-04-02)
------------------------------
http://github.com/mzp/atig/tree/v0.3.10
機能追加
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 一時ファイルの作成先を指定することができる --tmpdir オプションを追加しました
v0.3.9(2013-03-01)
------------------------------
http://github.com/mzp/atig/tree/v0.3.9
バグ修正
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Ruby 2.0 以降で動かした場合に Twitter のレスポンスを取得出来ない不具合を修正しました
v0.3.8(2013-02-03)
------------------------------
http://github.com/mzp/atig/tree/v0.3.8
機能変更
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- atig を rubygems からインストールしている場合はバージョンアップのチェックを行わないようにしました
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
......@@ -96,8 +200,6 @@ http://github.com/mzp/atig/tree/v0.3.0
バグ修正
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
v0.2.1(2010-04-17)
------------------------------
http://github.com/mzp/atig/tree/v0.2.1
......@@ -108,9 +210,9 @@ http://github.com/mzp/atig/tree/v0.2.1
- :doc:`irc`: `/topic` が `/me autofix` のエイリアスになりました。
- 最新の発言を削除した場合、トピック(topic)をひとつ前に戻すようにした
v0.2(2010-04-11)
v0.2.0(2010-04-11)
------------------------------
http://github.com/mzp/atig/tree/v0.2
http://github.com/mzp/atig/tree/v0.2.0
機能追加
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -123,10 +225,9 @@ http://github.com/mzp/atig/tree/v0.2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- followingの取得時にSSL Verified Errorが発生する不具合を修正
v0.1
v0.1.0(2010-04-11)
------------------------------
http://github.com/mzp/atig/tree/v0.1
http://github.com/mzp/atig/tree/v0.1.0
- 最初のリリース
......@@ -38,16 +38,16 @@ master_doc = 'index'
# General information about the project.
project = u'atig.rb'
copyright = u'2010, mzp'
copyright = u'2010-2013, mzp'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.3'
version = '0.4'
# The full version, including alpha/beta/rc tags.
release = '0.3.2'
release = '0.4.3'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -15,11 +15,11 @@ atig.rbはTwitterとIRCを結ぶゲートウェイです。
ダウンロード
------------------------------
- 安定板: `atigrb-0.3.4.tgz`_. ( `過去のバージョン`_ )
- 安定板: `atigrb-0.4.3.tgz`_. ( `過去のバージョン`_ )
- 開発版: `Github Repository`_.
.. _atigrb-0.3.4.tgz: http://github.com/mzp/atig/tarball/v0.3.4
.. _過去のバージョン: http://github.com/mzp/atig/downloads
.. _atigrb-0.4.3.tgz: http://github.com/mzp/atig/tarball/v0.4.3
.. _過去のバージョン: http://github.com/mzp/atig/tags
.. _GitHub Repository: http://github.com/mzp/atig
特徴
......
......@@ -36,32 +36,33 @@ only
発言関連
------------------------------
stream
`UserStream`_ を有効にします。
実行中の変更には対応していません。
footer=\ ``footer``
発言の末尾に、 ``footer`` を追加します。
ただし ``footer`` がfalseの場合は、追加しません。
old_style_reply
@nickで始まる発言が、@nick の最新の発言へのreplyとなるモードに切り替えます。
.. _UserStream: https://dev.twitter.com/docs/streaming-apis/streams/user
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 によって短縮します。
.. |len| replace:: 20
......
......@@ -36,7 +36,7 @@ trunk版
~~~~~~~~~~
githubからpullしてください。::
$ git pull http://mzp.github.com/atig
$ git clone https://github.com/mzp/atig.git
使ってみる
----------
......
# -*- coding: utf-8 -*-
$KCODE = "u" unless defined? ::Encoding # json use this
require 'atig/version'
require 'atig/monkey'
require 'atig/optparse'
......
require 'atig/agent/own_list'
require 'atig/agent/full_list'
require 'atig/agent/following'
require 'atig/agent/list_status'
......@@ -7,3 +6,4 @@ require 'atig/agent/dm'
require 'atig/agent/timeline'
require 'atig/agent/clenup'
require 'atig/agent/user_stream'
require 'atig/agent/noretweets'
......@@ -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
......
......@@ -22,15 +22,15 @@ module Atig
def update(api)
if @db.followings.empty?
friends = api.page("statuses/friends/#{@db.me.id}", :users)
friends = api.page("friends/list", :users, {:user_id => @db.me.id, :count => 100})
else
@db.me = api.post("account/update_profile")
return if @db.me.friends_count == @db.followings.size
friends = api.page("statuses/friends/#{@db.me.id}", :users)
friends = api.page("friends/list", :users, {:user_id => @db.me.id, :count => 100})
end
if @opts.only
followers = api.page("followers/ids/#{@db.me.id}", :ids)
followers = api.page("friends/ids", :ids, {:user_id => @db.me.id, :count => 2500})
friends.each do|friend|
friend[:only] = !followers.include?(friend.id)
end
......
......@@ -7,8 +7,8 @@ module Atig
module Agent
class FullList < List
def entry_points
[ "#{@db.me.screen_name}/lists",
"#{@db.me.screen_name}/lists/subscriptions"
[
"lists/list",
]
end
......
......@@ -12,16 +12,16 @@ module Atig
@db = db
log :info, "initialize"
@db.lists.on_invalidated{|name|
@db.lists.on_invalidated do |name|
log :info, "invalidated #{name}"
api.delay(0){|t|
api.delay(0) do |t|
if name == :all then
full_update t
else
@db.lists[name].update t.page("#{@db.me.screen_name}/#{name}/members", :users, true)
@db.lists[name].update t.page("lists/members", :users, {:owner_screen_name => @db.me.screen_name, :slug => name})
end
}
}
end
end
api.repeat( interval ) do|t|
self.full_update t
end
......@@ -29,11 +29,11 @@ module Atig
def full_update(t)
lists = entry_points.map{|entry|
t.page(entry, :lists, true)
}.flatten
t.get(entry)
}.flatten.compact
users = {}
lists.map do|list|
lists.map do |list|
name = if list.user.screen_name == @db.me.screen_name then
"#{list.slug}"
else
......@@ -41,8 +41,8 @@ module Atig
end
begin
users[name] =
t.page("#{list.user.screen_name}/#{list.slug}/members", :users, true)
rescue APIFailed => e
t.page("lists/members", :users, {:owner_screen_name => list.user.screen_name, :slug => list.slug})
rescue => e
log :error, e.inspect
users[name] =
@db.lists.find_by_list_name(list.slug)
......
......@@ -20,8 +20,9 @@ class Atig::Agent::ListStatus
q = {}
q.update(:since_id => @prev[name]) if @prev.key?(name)
screen_name,slug = parse name
statuses = t.get("#{screen_name}/lists/#{slug}/statuses",q)
screen_name, slug = parse name
q.update(:owner_screen_name => screen_name, :slug => slug)
statuses = t.get("lists/statuses", q)
statuses.reverse_each do|status|
db.statuses.transaction do|d|
d.add(:status => status,
......
......@@ -4,9 +4,12 @@ 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 path; '/statuses/mentions_timeline' end
def source; :mention end
end
end
......
# -*- 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_retweets/ids") )
end
end
end
end
# -*- mode:ruby; coding:utf-8 -*-
require 'atig/util'
require 'atig/agent/list'
module Atig
module Agent
class OtherList < List
def entry_points
[ "#{@db.me.screen_name}/lists/subscriptions" ]
end
def interval
3600
end
end
end
end
# -*- mode:ruby; coding:utf-8 -*-
require 'atig/util'
require 'atig/agent/list'
module Atig
module Agent
class OwnList < List
def entry_points
[ "#{@db.me.screen_name}/lists" ]
end
def interval
3600
end
end
end
end
......@@ -4,8 +4,18 @@ require 'atig/agent/agent'
module Atig
module Agent
class Timeline < Atig::Agent::Agent
def initialize(context, api, db); super end
def interval; 30 end
DEFAULT_INTERVAL = 60
def initialize(context, api, db)
@opts = context.opts
return if @opts.stream
super
end
def interval
@interval ||= @opts.interval.nil? ? DEFAULT_INTERVAL : @opts.interval.to_i
end
def path; '/statuses/home_timeline' end
def source; :timeline end
end
......
......@@ -16,12 +16,33 @@ module Atig
log :info, "initialize"
@api.stream do|t|
t.watch('user') do |status|
options = context.opts.allreplies ? {:replies => :all} : {}
t.watch('user', options) 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'