cinch-pskreporter 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 +37 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +4 -0
- data/Rakefile +5 -0
- data/cinch-pskreporter.gemspec +28 -0
- data/lib/cinch-pskreporter.rb +2 -0
- data/lib/cinch/plugins/pskreporter.rb +87 -0
- data/lib/cinch/plugins/pskreporter/version.rb +8 -0
- metadata +138 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 66793780f6f6482a594eda47a0644471fc3f83c1
|
4
|
+
data.tar.gz: 437510742e586fb79eb605d9531fd0258068b26a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6dffb8dc5c876382ac470166c17321ba0ea38e81c4e2d426936e6a17098775bf26dfdd929f928f83a442a84d7454d3e90b4a84fa8cb7fb71430c38b7585578af
|
7
|
+
data.tar.gz: 0faf4a06dfe55f01500fb094538d1a711c36da54429093602fb1284aba9cf17a95d60990c64fed11bf4e25692aa41d38bec42854ddd02e5d5a79a379859b4b6e
|
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/vendor/bundle
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
Gemfile.lock
|
31
|
+
.ruby-version
|
32
|
+
.ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
36
|
+
*~
|
37
|
+
\#*
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Jan Szumiec
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cinch/plugins/pskreporter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cinch-pskreporter"
|
8
|
+
spec.version = Cinch::Plugins::PSKReporter::VERSION
|
9
|
+
spec.authors = ["Jan Szumiec"]
|
10
|
+
spec.email = ["jan.szumiec@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Polls pskreporter.info every 10 minutes for reports for a particular callsign"
|
13
|
+
spec.homepage = "https://github.com/jasiek/cinch-pskreporter"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_development_dependency "rspec", "~> 3"
|
23
|
+
spec.add_development_dependency "cinch-test", "~> 0"
|
24
|
+
spec.add_development_dependency "byebug", "~> 0"
|
25
|
+
|
26
|
+
spec.add_dependency "cinch", "~> 2"
|
27
|
+
spec.add_dependency "hashie", "~> 0"
|
28
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'cinch'
|
2
|
+
require 'rexml/document'
|
3
|
+
require 'net/http'
|
4
|
+
require 'hashie/mash'
|
5
|
+
|
6
|
+
class Hash
|
7
|
+
def symbolize_keys
|
8
|
+
self.inject({}) do |h, (key, value)|
|
9
|
+
h.update(key.to_sym => value)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Cinch::Plugins
|
15
|
+
class PSKReporter
|
16
|
+
include Cinch::Plugin
|
17
|
+
|
18
|
+
self.help = "Every 10 minutes, talk to pskreporter.info and post RX reports"
|
19
|
+
|
20
|
+
timer 10, method: :check_pskreporter
|
21
|
+
|
22
|
+
def check_pskreporter
|
23
|
+
config[:watchers].each do |channel, callsigns|
|
24
|
+
callsigns.each do |callsign|
|
25
|
+
reports = pskreporter_reports(callsign, -10 * 60) # 10 minutes
|
26
|
+
msg_reports(channel, reports) if reports.any?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def pskreporter_reports(callsign, since_when)
|
32
|
+
body = Net::HTTP.get("http://retrieve.pskreporter.info/query?senderCallsign=#{callsign}&flowStartSeconds=#{since_when}&rronly=1")
|
33
|
+
doc = REXML::Document.new(body)
|
34
|
+
[].tap do |reports|
|
35
|
+
doc.each_element("//receptionReport") do |element|
|
36
|
+
reports << Hashie::Mash.new(element.attributes)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def msg_reports(channel, reports)
|
42
|
+
reports.each do |report|
|
43
|
+
Channel(channel).msg(report_text(report))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def report_text(r)
|
48
|
+
frequency = r.frequency.to_f / 1000
|
49
|
+
if d = self.class.distance(*[r.senderLocation, r.receiverLocation].map { |loc| self.class.coords_from_maidenhead(loc) })
|
50
|
+
"#{r.receiverCallsign} (#{r.receiverLocation}) heard #{r.senderCallsign} (#{r.senderLocation}) = #{d} km @ #{frequency} MHz using #{r.mode}"
|
51
|
+
else
|
52
|
+
"#{r.receiverCallsign} heard #{r.senderCallsign} @ #{frequency} MHz using #{r.mode}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.distance(c1, c2)
|
57
|
+
return nil unless c1 && c2
|
58
|
+
|
59
|
+
c1 = deg2rad(c1)
|
60
|
+
c2 = deg2rad(c2)
|
61
|
+
|
62
|
+
radius = 6371 # km
|
63
|
+
delta = (c1[1] - c2[1]).abs
|
64
|
+
radius * Math.acos(Math.sin(c1[0]) * Math.sin(c2[0]) + Math.cos(c1[0]) * Math.cos(c2[0]) * Math.cos(delta))
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.coords_from_maidenhead(grid)
|
68
|
+
return nil if grid.nil?
|
69
|
+
|
70
|
+
xxx, yyy, xx, yy, x, y = grid.upcase.split(//)
|
71
|
+
|
72
|
+
lon = (xxx.ord - 'A'.ord) * 20 - 180 + (xx.ord - '0'.ord) * 2
|
73
|
+
lat = (yyy.ord - 'A'.ord) * 10 - 90 + (yy.ord - '0'.ord) * 1
|
74
|
+
|
75
|
+
if x && y
|
76
|
+
lon += (x.ord - 'A'.ord) * 1.0/12
|
77
|
+
lat += (y.ord - 'A'.ord) * 1.0/24
|
78
|
+
end
|
79
|
+
|
80
|
+
[lat, lon]
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.deg2rad(coords)
|
84
|
+
coords.map { |c| c * Math::PI / 180 }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cinch-pskreporter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Szumiec
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '10.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '10.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cinch-test
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cinch
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: hashie
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- jan.szumiec@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- cinch-pskreporter.gemspec
|
111
|
+
- lib/cinch-pskreporter.rb
|
112
|
+
- lib/cinch/plugins/pskreporter.rb
|
113
|
+
- lib/cinch/plugins/pskreporter/version.rb
|
114
|
+
homepage: https://github.com/jasiek/cinch-pskreporter
|
115
|
+
licenses:
|
116
|
+
- MIT
|
117
|
+
metadata: {}
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 2.4.3
|
135
|
+
signing_key:
|
136
|
+
specification_version: 4
|
137
|
+
summary: Polls pskreporter.info every 10 minutes for reports for a particular callsign
|
138
|
+
test_files: []
|