qqbot 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/qqbot.rb +17 -0
- data/lib/qqbot/api.rb +42 -0
- data/lib/qqbot/auth.rb +180 -0
- data/lib/qqbot/bot.rb +41 -0
- data/lib/qqbot/client.rb +67 -0
- data/lib/qqbot/cookie.rb +28 -0
- data/lib/qqbot/version.rb +3 -0
- data/qqbot.gemspec +33 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fa9640a3b0d1829afb8e8a597d505583d918ca86
|
4
|
+
data.tar.gz: 9f598d3abf7f85314c655c308cc94b89254206f4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6256bf3d5c525b7d1f63aa98edf6c83ea5c46bb9417c74d287a428ff0ae88ab6a5a180748b08fcb8f57bac7e3dca77fff3acd16ca656f23579aa8d74d1b62740
|
7
|
+
data.tar.gz: a0bc8fb618dcb78e375ca05f31cb6bdd221dca51a625eaf29d3eb39b88c3d2420037ebf1f1be68767eda25eec84d56aaca70b85bb947ebb95cca44a95a5a566a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at xie_enlong@foxmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 ScienJus
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# QQBot
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/qqbot`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'qqbot'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install qqbot
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ScienJus/qqbot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "qqbot"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/qqbot.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'qqbot/version'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
module QQBot
|
5
|
+
|
6
|
+
LOGGER = Logger.new(STDOUT)
|
7
|
+
|
8
|
+
autoload :Auth, 'qqbot/auth'
|
9
|
+
autoload :Cookie, 'qqbot/cookie'
|
10
|
+
autoload :Client, 'qqbot/client'
|
11
|
+
autoload :Api, 'qqbot/api'
|
12
|
+
autoload :Bot, 'qqbot/bot'
|
13
|
+
|
14
|
+
def self.new
|
15
|
+
QQBot::Bot.new
|
16
|
+
end
|
17
|
+
end
|
data/lib/qqbot/api.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'json'
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
module QQBot
|
6
|
+
class Api
|
7
|
+
|
8
|
+
def initialize(client, options = {})
|
9
|
+
@client = client
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def poll
|
14
|
+
uri = URI('http://d1.web2.qq.com/channel/poll2')
|
15
|
+
|
16
|
+
r = JSON.generate(
|
17
|
+
ptwebqq: @options[:ptwebqq],
|
18
|
+
clientid: 53999199,
|
19
|
+
psessionid: @options[:psessionid],
|
20
|
+
key: ''
|
21
|
+
)
|
22
|
+
|
23
|
+
begin
|
24
|
+
code, body = @client.post(uri, 'http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2', r: r)
|
25
|
+
rescue [ExceptionType = Net::ReadTimeout]
|
26
|
+
return
|
27
|
+
end
|
28
|
+
|
29
|
+
if code == '200'
|
30
|
+
json = JSON.parse body
|
31
|
+
if json['retcode'] == 0
|
32
|
+
return json['result']
|
33
|
+
else
|
34
|
+
QQBot::LOGGER.info "获取消息失败 返回码 #{json['retcode']}"
|
35
|
+
end
|
36
|
+
else
|
37
|
+
QQBot::LOGGER.info "请求失败,返回码#{code}"
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/qqbot/auth.rb
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'json'
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
module QQBot
|
6
|
+
class Auth
|
7
|
+
|
8
|
+
def initialize client
|
9
|
+
@client = client
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_qrcode
|
13
|
+
QQBot::LOGGER.info '开始获取二维码'
|
14
|
+
|
15
|
+
uri = URI('https://ssl.ptlogin2.qq.com/ptqrshow');
|
16
|
+
|
17
|
+
uri.query =
|
18
|
+
URI.encode_www_form(
|
19
|
+
appid: 501004106,
|
20
|
+
e: 0,
|
21
|
+
l: :M,
|
22
|
+
s: 5,
|
23
|
+
d: 72,
|
24
|
+
v: 4,
|
25
|
+
t: 0.1,
|
26
|
+
)
|
27
|
+
|
28
|
+
code, body = @client.get uri
|
29
|
+
|
30
|
+
if code == '200'
|
31
|
+
file_name = File.expand_path('qrcode.png', File.dirname(__FILE__));
|
32
|
+
|
33
|
+
File.open(file_name, 'wb') do |file|
|
34
|
+
file.write body
|
35
|
+
file.close
|
36
|
+
end
|
37
|
+
|
38
|
+
QQBot::LOGGER.info "二维码已经保存在#{file_name}中"
|
39
|
+
|
40
|
+
if @pid == nil
|
41
|
+
QQBot::LOGGER.info '开启web服务进程'
|
42
|
+
|
43
|
+
@pid = spawn("ruby -run -e httpd #{file_name} -p 9090", out: '/dev/null')
|
44
|
+
end
|
45
|
+
|
46
|
+
QQBot::LOGGER.info '也可以通过访问 http://localhost:9090 查看二维码'
|
47
|
+
else
|
48
|
+
QQBot::LOGGER.info "请求失败,返回码#{code}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def verify_qrcode
|
53
|
+
QQBot::LOGGER.info '等待扫描二维码'
|
54
|
+
|
55
|
+
uri = URI('https://ssl.ptlogin2.qq.com/ptqrlogin');
|
56
|
+
uri.query =
|
57
|
+
URI.encode_www_form(
|
58
|
+
webqq_type: 10,
|
59
|
+
remember_uin: 1,
|
60
|
+
login2qq: 1,
|
61
|
+
aid: 501004106,
|
62
|
+
u1: 'http://Fw.qq.com/proxy.html?login2qq=1&webqq_type=10',
|
63
|
+
ptredirect: 0,
|
64
|
+
ptlang: 2052,
|
65
|
+
daid: 164,
|
66
|
+
from_ui: 1,
|
67
|
+
pttype: 1,
|
68
|
+
dumy: '',
|
69
|
+
fp: 'loginerroralert',
|
70
|
+
action: '0-0-157510',
|
71
|
+
mibao_css: 'm_webqq',
|
72
|
+
t: 1,
|
73
|
+
g: 1,
|
74
|
+
js_type: 0,
|
75
|
+
js_ver: 10143,
|
76
|
+
login_sig: '',
|
77
|
+
pt_randsalt: 0,
|
78
|
+
)
|
79
|
+
|
80
|
+
code, body = @client.get uri
|
81
|
+
|
82
|
+
if code == '200'
|
83
|
+
result = body.force_encoding("UTF-8")
|
84
|
+
if result.include? '二维码已失效'
|
85
|
+
QQBot::LOGGER.info '二维码已失效,请重新获取'
|
86
|
+
return '-1'
|
87
|
+
elsif result.include? 'http'
|
88
|
+
QQBot::LOGGER.info '认证成功'
|
89
|
+
unless @pid == nil
|
90
|
+
QQBot::LOGGER.info '关闭web服务进程'
|
91
|
+
system "kill -9 #{@pid}"
|
92
|
+
end
|
93
|
+
return URI.extract(result)[0]
|
94
|
+
else
|
95
|
+
return '0'
|
96
|
+
end
|
97
|
+
else
|
98
|
+
QQBot::LOGGER.info "请求失败,返回码#{code}"
|
99
|
+
return '0'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def get_ptwebqq url
|
104
|
+
QQBot::LOGGER.info '开始获取ptwebqq'
|
105
|
+
|
106
|
+
uri = URI(url);
|
107
|
+
|
108
|
+
code, body = @client.get(uri, 'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1')
|
109
|
+
|
110
|
+
if code == '302'
|
111
|
+
@ptwebqq = @client.get_cookie :ptwebqq
|
112
|
+
else
|
113
|
+
QQBot::LOGGER.info "请求失败,返回码#{code}"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def get_vfwebqq
|
118
|
+
QQBot::LOGGER.info '开始获取vfwebqq'
|
119
|
+
|
120
|
+
uri = URI('http://s.web2.qq.com/api/getvfwebqq');
|
121
|
+
|
122
|
+
uri.query =
|
123
|
+
URI.encode_www_form(
|
124
|
+
ptwebqq: @ptwebqq,
|
125
|
+
clientid: 53999199,
|
126
|
+
psessionid: '',
|
127
|
+
t: 0.1,
|
128
|
+
)
|
129
|
+
|
130
|
+
code, body = @client.get(uri, 'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1')
|
131
|
+
|
132
|
+
if code == '200'
|
133
|
+
json = JSON.parse body
|
134
|
+
if json['retcode'] == 0
|
135
|
+
@vfwebqq = json['result']['vfwebqq']
|
136
|
+
else
|
137
|
+
QQBot::LOGGER.info "获取vfwebqq失败 返回码 #{json['retcode']}"
|
138
|
+
end
|
139
|
+
else
|
140
|
+
QQBot::LOGGER.info "请求失败,返回码#{code}"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def get_psessionid_and_uin
|
145
|
+
QQBot::LOGGER.info '开始获取psessionid和uin'
|
146
|
+
|
147
|
+
uri = URI('http://d1.web2.qq.com/channel/login2');
|
148
|
+
|
149
|
+
r = JSON.generate(
|
150
|
+
ptwebqq: @ptwebqq,
|
151
|
+
clientid: 53999199,
|
152
|
+
psessionid: '',
|
153
|
+
status: 'online'
|
154
|
+
)
|
155
|
+
|
156
|
+
code, body = @client.post(uri, 'http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2', r: r)
|
157
|
+
|
158
|
+
if code == '200'
|
159
|
+
json = JSON.parse body
|
160
|
+
if json['retcode'] == 0
|
161
|
+
@uin = json['result']['uin']
|
162
|
+
@psessionid = json['result']['psessionid']
|
163
|
+
else
|
164
|
+
QQBot::LOGGER.info "获取vfwebqq失败 返回码 #{json['retcode']}"
|
165
|
+
end
|
166
|
+
else
|
167
|
+
QQBot::LOGGER.info "请求失败,返回码#{code}"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def options
|
172
|
+
{
|
173
|
+
ptwebqq: @ptwebqq,
|
174
|
+
vfwebqq: @vfwebqq,
|
175
|
+
psessionid: @psessionid,
|
176
|
+
uin: @uin
|
177
|
+
}
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
data/lib/qqbot/bot.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
module QQBot
|
2
|
+
class Bot
|
3
|
+
def initialize
|
4
|
+
@client = QQBot::Client.new
|
5
|
+
@auth = QQBot::Auth.new @client
|
6
|
+
end
|
7
|
+
|
8
|
+
def login
|
9
|
+
@auth.get_qrcode
|
10
|
+
|
11
|
+
url = ''
|
12
|
+
|
13
|
+
until url.start_with? 'http' do
|
14
|
+
sleep 5
|
15
|
+
url = @auth.verify_qrcode
|
16
|
+
@auth.get_qrcode if url == '-1'
|
17
|
+
end
|
18
|
+
|
19
|
+
@auth.get_ptwebqq url
|
20
|
+
|
21
|
+
@auth.get_vfwebqq
|
22
|
+
|
23
|
+
@auth.get_psessionid_and_uin
|
24
|
+
|
25
|
+
auth_options = @auth.options
|
26
|
+
|
27
|
+
@api = QQBot::Api.new(@client, auth_options)
|
28
|
+
end
|
29
|
+
|
30
|
+
def poll
|
31
|
+
return if @api.nil?
|
32
|
+
|
33
|
+
loop do
|
34
|
+
@api.poll
|
35
|
+
sleep 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/lib/qqbot/client.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'openssl'
|
3
|
+
|
4
|
+
module QQBot
|
5
|
+
class Client
|
6
|
+
|
7
|
+
@@user_agent = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36';
|
8
|
+
|
9
|
+
def self.origin uri
|
10
|
+
uri.scheme + '://' + uri.host
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@cookie = QQBot::Cookie.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def get(uri, referer = '')
|
18
|
+
Net::HTTP.start(uri.host, uri.port,
|
19
|
+
use_ssl: uri.scheme == 'https',
|
20
|
+
verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
|
21
|
+
|
22
|
+
req = Net::HTTP::Get.new uri
|
23
|
+
|
24
|
+
req.initialize_http_header(
|
25
|
+
'User-Agent' => @@user_agent,
|
26
|
+
'Cookie' => @cookie.to_s,
|
27
|
+
'Referer' => referer
|
28
|
+
)
|
29
|
+
|
30
|
+
res = http.request req
|
31
|
+
|
32
|
+
@cookie.put res.get_fields('set-cookie')
|
33
|
+
|
34
|
+
return res.code, res.body
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def post(uri, referer = '', form_data = {})
|
39
|
+
Net::HTTP.start(uri.host, uri.port,
|
40
|
+
use_ssl: uri.scheme == 'https',
|
41
|
+
verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
|
42
|
+
|
43
|
+
req = Net::HTTP::Post.new uri
|
44
|
+
|
45
|
+
req.set_form_data(form_data)
|
46
|
+
|
47
|
+
req.initialize_http_header(
|
48
|
+
'User-Agent' => @@user_agent,
|
49
|
+
'Cookie' => @cookie.to_s,
|
50
|
+
'Referer' => referer,
|
51
|
+
'Origin' => self.class.origin(uri)
|
52
|
+
)
|
53
|
+
|
54
|
+
res = http.request req
|
55
|
+
|
56
|
+
@cookie.put res.get_fields('set-cookie')
|
57
|
+
|
58
|
+
return res.code, res.body
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_cookie key
|
64
|
+
@cookie[key]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/qqbot/cookie.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module QQBot
|
2
|
+
class Cookie
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@cookies = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def put set_cookie_array
|
9
|
+
return if set_cookie_array == nil
|
10
|
+
|
11
|
+
set_cookie_array.each do |set_cookie|
|
12
|
+
set_cookie.split('; ').each do |cookie|
|
13
|
+
k, v = cookie.split('=')
|
14
|
+
@cookies[k] = v unless v == nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def [] key
|
20
|
+
@cookies[key] || ''
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_s
|
24
|
+
@cookies.map{ |k, v| "#{k}=#{v}" }.join('; ')
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/qqbot.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'qqbot/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "qqbot"
|
8
|
+
spec.version = QQBot::VERSION
|
9
|
+
spec.authors = ["ScienJus"]
|
10
|
+
spec.email = ["i@scienjus.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{a qq bot based on smart qq(web qq).}
|
13
|
+
spec.description = %q{a qq bot based on smart qq api.?}
|
14
|
+
spec.homepage = "https://github.com/ScienJus/qqbot"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qqbot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ScienJus
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: a qq bot based on smart qq api.?
|
56
|
+
email:
|
57
|
+
- i@scienjus.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- CODE_OF_CONDUCT.md
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- lib/qqbot.rb
|
73
|
+
- lib/qqbot/api.rb
|
74
|
+
- lib/qqbot/auth.rb
|
75
|
+
- lib/qqbot/bot.rb
|
76
|
+
- lib/qqbot/client.rb
|
77
|
+
- lib/qqbot/cookie.rb
|
78
|
+
- lib/qqbot/version.rb
|
79
|
+
- qqbot.gemspec
|
80
|
+
homepage: https://github.com/ScienJus/qqbot
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata:
|
84
|
+
allowed_push_host: https://rubygems.org
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.4.8
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: a qq bot based on smart qq(web qq).
|
105
|
+
test_files: []
|