summaryrefslogtreecommitdiff
path: root/lib/rbot/ircsocket.rb
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-12-12 20:59:34 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-12-12 21:40:20 +0100
commit1579c60ee8ad2cb24eadbec66bfe3710775b2a05 (patch)
tree0a9eb19fb06905d6703c4e881abdb88c7c9b4e85 /lib/rbot/ircsocket.rb
parentf11630a55cf8775ccf021fa769404af7ef8e5aa1 (diff)
ircsocket: tunable IRC penalty
Diffstat (limited to 'lib/rbot/ircsocket.rb')
-rw-r--r--lib/rbot/ircsocket.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/rbot/ircsocket.rb b/lib/rbot/ircsocket.rb
index 9adca6ba..36a223f9 100644
--- a/lib/rbot/ircsocket.rb
+++ b/lib/rbot/ircsocket.rb
@@ -246,6 +246,9 @@ module Irc
# normalized uri of the current server
attr_reader :server_uri
+ # penalty multiplier (percent)
+ attr_accessor :penalty_pct
+
# default trivial filter class
class IdentityFilter
def in(x)
@@ -276,6 +279,7 @@ module Irc
@lines_sent = 0
@lines_received = 0
@ssl = opts[:ssl]
+ @penalty_pct = opts[:penalty_pct] || 100
end
def connected?
@@ -433,7 +437,7 @@ module Irc
@sock.syswrite actual
@last_send = now
@flood_send = now if @flood_send < now
- @flood_send += message.irc_send_penalty if penalty
+ @flood_send += message.irc_send_penalty*@penalty_pct/100.0 if penalty
@lines_sent += 1
end
rescue Exception => e