amazon2irc 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +17 -0
- data/Rakefile +6 -0
- data/amazon2irc.gemspec +36 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/amazon2irc/version.rb +3 -0
- data/lib/amazon2irc.rb +85 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9f1ef2ff2f22f492c9a9535437abbddeca4b1246
|
4
|
+
data.tar.gz: 5f6b342226435c1ea95cafeabd2f6028f995227f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 946abe86aa1f8316c2e813caa59210b6d889b278cf621c2626d0840a4f0d7e995ca89b05bbf1fc93fc284c2c63318e654648a0b61c680a7e35fa02818f2993e6
|
7
|
+
data.tar.gz: 579cec4f8c6296299a2f8203b51ec4239949623990350bb0f4d44d6099b897200d2193aca6e67217184b5307008195062a3ab9c6d6ddd9a95fc6499f97da961c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 jlee
|
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,17 @@
|
|
1
|
+
Install gem: gem install amazon2irc
|
2
|
+
|
3
|
+
|
4
|
+
Demo:
|
5
|
+
|
6
|
+
require 'amazon2irc'
|
7
|
+
|
8
|
+
opts = {}
|
9
|
+
opts['botnick'] = "JayCorpIncRBot"
|
10
|
+
opts['server'] = "irc.freenode.net"
|
11
|
+
opts['port'] = "6667"
|
12
|
+
opts['channel'] = "\#jaycorpinc"
|
13
|
+
opts['keywords']= [ 'ryzen', 'atx', 'projector', 'x370', 'motherboard', 'atx case', 'm.2', 'projector screen', 'seasonic', 'ddr-3200', '4k']
|
14
|
+
opts['chat-delay']=1.5
|
15
|
+
opts['scan-delay']=30
|
16
|
+
|
17
|
+
Amazon2irc::Process.new(opts)
|
data/Rakefile
ADDED
data/amazon2irc.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "amazon2irc/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "amazon2irc"
|
8
|
+
spec.version = Amazon2irc::VERSION
|
9
|
+
spec.authors = ["jlee"]
|
10
|
+
spec.email = ["jlee@ruby.im"]
|
11
|
+
|
12
|
+
spec.summary = %q{Post Amazon Deals to IRC.}
|
13
|
+
spec.description = %q{Post unique Amazon Deals to IRC}
|
14
|
+
spec.homepage = "http://ruby.im"
|
15
|
+
spec.license = "PIRATE"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
#if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
#else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
#end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "amazon2irc"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/lib/amazon2irc.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
require "amazon2irc/version"
|
2
|
+
|
3
|
+
module Amazon2irc
|
4
|
+
class Process
|
5
|
+
attr_accessor :conn
|
6
|
+
def initialize opts
|
7
|
+
@opts = opts
|
8
|
+
@items = []
|
9
|
+
init_persistent_array
|
10
|
+
connect
|
11
|
+
wait
|
12
|
+
loop do
|
13
|
+
scanning
|
14
|
+
write_persistent_array
|
15
|
+
sleep @opts['scan-delay']
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def init_persistent_array
|
21
|
+
unless File.exist? File.expand_path "store.yml"
|
22
|
+
open('store.yml', 'w') {|f| YAML.dump(@items, f)}
|
23
|
+
end
|
24
|
+
load_persistent_array
|
25
|
+
end
|
26
|
+
|
27
|
+
def load_persistent_array
|
28
|
+
@items = open('store.yml') {|f| YAML.load(f) }
|
29
|
+
end
|
30
|
+
|
31
|
+
def write_persistent_array
|
32
|
+
open('store.yml', 'w') {|f| YAML.dump(@items, f)}
|
33
|
+
end
|
34
|
+
|
35
|
+
def connect
|
36
|
+
@conn = TCPSocket.open(@opts['server'], @opts['port'])
|
37
|
+
print("addr: ", @conn.addr.join(":"), "\n")
|
38
|
+
print("peer: ", @conn.peeraddr.join(":"), "\n")
|
39
|
+
@conn.puts "USER testing 0 * Testing"
|
40
|
+
@conn.puts "NICK #{@opts['botnick']}"
|
41
|
+
@conn.puts "JOIN #{@opts['channel']}"
|
42
|
+
@conn.puts "PRIVMSG #{@opts['channel']} :Bot Scanning: #{@opts['keywords'].flatten}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def wait
|
46
|
+
(1..10).each do |i|
|
47
|
+
msg = @conn.gets
|
48
|
+
puts msg
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def scanning
|
54
|
+
parse(pullDeals)
|
55
|
+
@conn.puts "PRIVMSG #{@opts['channel']} :Bot Scanned: #{@opts['keywords'].flatten}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def pullDeals
|
59
|
+
rss = RSS::Parser.parse('https://rssfeeds.s3.amazonaws.com/goldbox', false)
|
60
|
+
rss.items
|
61
|
+
end
|
62
|
+
|
63
|
+
def parse items
|
64
|
+
items.each do |item|
|
65
|
+
unless @items.include? "#{item.title}"
|
66
|
+
kw_match(item)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def kw_match item
|
72
|
+
@opts['keywords'].each do |kw|
|
73
|
+
if item.title.downcase.include? kw.downcase
|
74
|
+
irc_logger(item)
|
75
|
+
@items.push("#{item.title}")
|
76
|
+
sleep @opts['chat-delay']
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def irc_logger item
|
82
|
+
@conn.puts "PRIVMSG #{@opts['channel']} :#{item.title} - #{item.link}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: amazon2irc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jlee
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-10 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.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
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: Post unique Amazon Deals to IRC
|
56
|
+
email:
|
57
|
+
- jlee@ruby.im
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- amazon2irc.gemspec
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- lib/amazon2irc.rb
|
73
|
+
- lib/amazon2irc/version.rb
|
74
|
+
homepage: http://ruby.im
|
75
|
+
licenses:
|
76
|
+
- PIRATE
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.5.1
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Post Amazon Deals to IRC.
|
98
|
+
test_files: []
|