potato 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/potato/damn/events.rb +6 -1
- data/lib/potato/damn/token.rb +17 -0
- data/lib/potato/irc/client.rb +5 -0
- data/lib/potato/irc/events.rb +4 -15
- data/lib/potato/irc/server.rb +6 -1
- data/lib/potato/version.rb +1 -1
- metadata +26 -31
data/lib/potato/damn/events.rb
CHANGED
@@ -6,7 +6,12 @@ module Potato
|
|
6
6
|
# @param [DAmn::Packet] pkt
|
7
7
|
# @return [void]
|
8
8
|
def on_login pkt
|
9
|
-
|
9
|
+
if pkt.ok?
|
10
|
+
@user.logged_in = true
|
11
|
+
else
|
12
|
+
@user.notice "Login failure: #{pkt.error}"
|
13
|
+
@user.close
|
14
|
+
end
|
10
15
|
end
|
11
16
|
|
12
17
|
# @param [DAmn::Packet] pkt
|
data/lib/potato/damn/token.rb
CHANGED
@@ -15,6 +15,19 @@ module Potato
|
|
15
15
|
end.join("&")
|
16
16
|
end
|
17
17
|
|
18
|
+
def wait_for_internet
|
19
|
+
begin
|
20
|
+
s = TCPSocket.new("google.com", 80)
|
21
|
+
s.close
|
22
|
+
rescue Errno::ECONNREFUSED
|
23
|
+
return true
|
24
|
+
rescue SocketError
|
25
|
+
sleep 10
|
26
|
+
retry
|
27
|
+
end
|
28
|
+
return true
|
29
|
+
end
|
30
|
+
|
18
31
|
# Gets an authtoken.
|
19
32
|
# @param [String] username
|
20
33
|
# @param [String] password
|
@@ -46,6 +59,10 @@ module Potato
|
|
46
59
|
rescue Errno::ECONNRESET
|
47
60
|
warn "Connection reset by peer when attempting to retrieve authtoken."
|
48
61
|
nil
|
62
|
+
rescue SocketError
|
63
|
+
warn "Lost internet connection. Waiting for availability."
|
64
|
+
wait_for_internet
|
65
|
+
retry
|
49
66
|
end
|
50
67
|
end
|
51
68
|
end
|
data/lib/potato/irc/client.rb
CHANGED
data/lib/potato/irc/events.rb
CHANGED
@@ -72,25 +72,15 @@ module Potato
|
|
72
72
|
# @return [void]
|
73
73
|
def on_pass pkt
|
74
74
|
notice "Attempting to retrieve authtoken."
|
75
|
-
|
76
|
-
tok = Timeout::timeout(30) {
|
77
|
-
Potato::DAmn::Token.get(@config.nick, pkt.args[0])
|
78
|
-
}
|
79
|
-
rescue Timeout::Error
|
80
|
-
notice "dAmn server is down. Try again later."
|
81
|
-
@client.quit
|
82
|
-
@socket.close
|
83
|
-
return
|
84
|
-
end
|
75
|
+
tok = Potato::DAmn::Token.get(@config.nick, pkt.args[0])
|
85
76
|
if tok.nil?
|
86
77
|
notice "Unable to retrieve an authtoken (server didn't respond)."
|
87
|
-
|
88
|
-
@socket.close
|
78
|
+
close
|
89
79
|
return
|
90
80
|
elsif tok.empty?
|
91
81
|
notice "Wrong password or username. (no authtoken retrieved)"
|
92
82
|
else
|
93
|
-
notice "
|
83
|
+
notice "Authtoken retrieved successfully."
|
94
84
|
@logged_in = true
|
95
85
|
@config.token = tok
|
96
86
|
@client.connect_with(@config.nick, @config.token)
|
@@ -130,8 +120,7 @@ module Potato
|
|
130
120
|
# @param [IRC::Packet] pkt
|
131
121
|
# @return [void]
|
132
122
|
def on_quit pkt
|
133
|
-
|
134
|
-
@socket.close
|
123
|
+
close
|
135
124
|
end
|
136
125
|
end
|
137
126
|
end
|
data/lib/potato/irc/server.rb
CHANGED
@@ -63,7 +63,12 @@ module Potato
|
|
63
63
|
end
|
64
64
|
@connections = {}
|
65
65
|
end
|
66
|
-
|
66
|
+
unless pkt.nil?
|
67
|
+
debug pkt.raw, :damn
|
68
|
+
else
|
69
|
+
cl.notice "Lost connection to dAmn (server closed connection)."
|
70
|
+
cl.socket.close
|
71
|
+
end
|
67
72
|
client = @connections.values.find{|x|x.client.server == action}.client
|
68
73
|
client.send("on_#{pkt.cmd}".to_sym, pkt) if client.respond_to?("on_#{pkt.cmd}".to_sym)
|
69
74
|
else
|
data/lib/potato/version.rb
CHANGED
metadata
CHANGED
@@ -1,28 +1,27 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: potato
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.13
|
4
5
|
prerelease:
|
5
|
-
version: 0.0.12
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Joel Taylor
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
12
|
+
date: 2011-04-27 00:00:00.000000000 -04:00
|
13
|
+
default_executable:
|
14
14
|
dependencies: []
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
description: Potato is an IRC server that communicates with the deviantART Message
|
16
|
+
Network and allows you to treat it like a regular IRC server, with support for user
|
17
|
+
modes, kicks/bans, /whois-ing, etc.
|
18
|
+
email:
|
18
19
|
- holla@joeldt.net
|
19
|
-
executables:
|
20
|
+
executables:
|
20
21
|
- potato
|
21
22
|
extensions: []
|
22
|
-
|
23
23
|
extra_rdoc_files: []
|
24
|
-
|
25
|
-
files:
|
24
|
+
files:
|
26
25
|
- .gitignore
|
27
26
|
- .yardopts
|
28
27
|
- README.md
|
@@ -41,33 +40,29 @@ files:
|
|
41
40
|
- lib/potato/irc/user.rb
|
42
41
|
- lib/potato/version.rb
|
43
42
|
- potato.gemspec
|
44
|
-
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: ''
|
45
45
|
licenses: []
|
46
|
-
|
47
46
|
post_install_message:
|
48
47
|
rdoc_options: []
|
49
|
-
|
50
|
-
require_paths:
|
48
|
+
require_paths:
|
51
49
|
- lib
|
52
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
51
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
57
|
none: false
|
60
|
-
requirements:
|
61
|
-
- -
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version:
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
64
62
|
requirements: []
|
65
|
-
|
66
63
|
rubyforge_project: potato
|
67
|
-
rubygems_version: 1.
|
64
|
+
rubygems_version: 1.6.2
|
68
65
|
signing_key:
|
69
66
|
specification_version: 3
|
70
67
|
summary: A dAmn <=> IRC proxy.
|
71
68
|
test_files: []
|
72
|
-
|
73
|
-
has_rdoc:
|