hwping 0.0.1 → 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hwping/bot.rb +17 -17
- data/lib/hwping/config.rb +6 -6
- data/lib/hwping/constants.rb +1 -1
- data/lib/hwping/hwping.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12b5f7585b1225c1e90d2a487c2d5f530c272d64
|
4
|
+
data.tar.gz: d205c225b205e58a8b38f9a51b504a4c32d9e9eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ccd7294ada3df2970c0f203b0968ec47f1e6808dce9d50e8ca60f0eef577d8ea6eef302d4f1e0cd3abaccb78da7d09e8a6ddc896afff95db030d20f42debd95
|
7
|
+
data.tar.gz: e1cd1ad3cf79e525d3d6804144d252edf0c6c5f41aaf80961739dd668c9341e05b524df3a72ef061c71cbae4cdac5e34d1b97202b67711171088e7baa371abce
|
data/lib/hwping/bot.rb
CHANGED
@@ -32,36 +32,36 @@ module HWPing
|
|
32
32
|
|
33
33
|
# Initialize a bot and return with its Cinch instance
|
34
34
|
def initialize(handler, config = {})
|
35
|
-
@
|
36
|
-
@server = config.server
|
37
|
-
@port = config.port
|
38
|
-
@channels = config.channels.map { |m| "\##{m}"}
|
39
|
-
@handler = handler
|
40
|
-
return setup_bot()
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
def setup_bot
|
45
|
-
bot = Cinch::Bot.new do |b|
|
35
|
+
@bot = Cinch::Bot.new do |b|
|
46
36
|
configure do |c|
|
47
|
-
c.nick =
|
48
|
-
c.server =
|
49
|
-
c.port =
|
50
|
-
c.channels =
|
37
|
+
c.nick = config.nick
|
38
|
+
c.server = config.server
|
39
|
+
c.port = config.port
|
40
|
+
c.channels = config.channels.map { |m| "\##{m}"}
|
51
41
|
end
|
52
42
|
|
53
43
|
# For channel mesages, just reply with the matching message
|
54
44
|
on :channel, /^hwping/ do |e|
|
55
|
-
r =
|
45
|
+
r = handler.channel(e)
|
56
46
|
e.reply(MESSAGES[r])
|
57
47
|
end
|
58
48
|
|
59
49
|
# For private messages, build a reply message from the format strinc and the passed variables
|
60
50
|
on :private do |e|
|
61
|
-
(r, *f) =
|
51
|
+
(r, *f) = handler.private(e)
|
62
52
|
e.reply(MESSAGES[r] % f)
|
63
53
|
end
|
64
54
|
end
|
65
55
|
end
|
56
|
+
|
57
|
+
# Start the bot
|
58
|
+
def start
|
59
|
+
@bot.start
|
60
|
+
end
|
61
|
+
|
62
|
+
# Stop the bot
|
63
|
+
def stop
|
64
|
+
@bot.quit
|
65
|
+
end
|
66
66
|
end
|
67
67
|
end
|
data/lib/hwping/config.rb
CHANGED
@@ -9,12 +9,12 @@ module HWPing
|
|
9
9
|
attr_accessor :targets
|
10
10
|
|
11
11
|
def initialize(hash = {})
|
12
|
-
@server = hash.fetch(
|
13
|
-
@port = hash.fetch(
|
14
|
-
@nick = hash.fetch(
|
15
|
-
@channels = hash.fetch(
|
16
|
-
@auth = hash.fetch(
|
17
|
-
@targets = hash.fetch(
|
12
|
+
@server = hash.fetch('server', 'irc.freenode.net')
|
13
|
+
@port = hash.fetch('port', 6667)
|
14
|
+
@nick = hash.fetch('nick', 'hwping')
|
15
|
+
@channels = hash.fetch('channels', ['hwping-test'])
|
16
|
+
@auth = hash.fetch('auth' , [])
|
17
|
+
@targets = hash.fetch('targets', [])
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_hash
|
data/lib/hwping/constants.rb
CHANGED
data/lib/hwping/hwping.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hwping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dávid Halász
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libusb
|