mod_spox 0.1.0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/CHANGELOG +36 -0
  2. data/INSTALL +2 -2
  3. data/README +0 -1
  4. data/bin/mod_spox +51 -12
  5. data/data/mod_spox/extras/AOLSpeak.rb +5 -18
  6. data/data/mod_spox/extras/AutoKick.rb +44 -23
  7. data/data/mod_spox/extras/AutoMode.rb +2 -5
  8. data/data/mod_spox/extras/AutoRejoin.rb +21 -0
  9. data/data/mod_spox/extras/Bouncer.rb +10 -10
  10. data/data/mod_spox/extras/Bytes.rb +12 -0
  11. data/data/mod_spox/extras/Confess.rb +131 -52
  12. data/data/mod_spox/extras/DCC.rb +189 -0
  13. data/data/mod_spox/extras/DevWatch.rb +32 -33
  14. data/data/mod_spox/extras/FloodKicker.rb +129 -0
  15. data/data/mod_spox/extras/GoogleIt.rb +13 -0
  16. data/data/mod_spox/extras/Headers.rb +31 -4
  17. data/data/mod_spox/extras/Karma.rb +103 -49
  18. data/data/mod_spox/extras/Logger.rb +45 -30
  19. data/data/mod_spox/extras/LolSpeak.rb +1 -1
  20. data/data/mod_spox/extras/NickServ.rb +83 -0
  21. data/data/mod_spox/extras/PhpCli.rb +12 -15
  22. data/data/mod_spox/extras/PhpFuncLookup.rb +57 -25
  23. data/data/mod_spox/extras/Quotes.rb +5 -4
  24. data/data/mod_spox/extras/RegexTracker.rb +160 -0
  25. data/data/mod_spox/extras/Roulette.rb +22 -23
  26. data/data/mod_spox/extras/Search.rb +3 -2
  27. data/data/mod_spox/extras/Slashdot.rb +35 -0
  28. data/data/mod_spox/extras/Topten.rb +5 -5
  29. data/data/mod_spox/extras/TracTicket.rb +68 -0
  30. data/data/mod_spox/extras/Translate.rb +69 -30
  31. data/data/mod_spox/extras/Twitter.rb +372 -0
  32. data/data/mod_spox/extras/UrbanDictionary.rb +21 -12
  33. data/data/mod_spox/extras/Weather.rb +1 -1
  34. data/data/mod_spox/plugins/Authenticator.rb +63 -30
  35. data/data/mod_spox/plugins/Banner.rb +164 -151
  36. data/data/mod_spox/plugins/Helper.rb +18 -7
  37. data/data/mod_spox/plugins/PluginLoader.rb +46 -22
  38. data/data/mod_spox/plugins/PoolConfig.rb +52 -0
  39. data/data/mod_spox/plugins/Quitter.rb +1 -1
  40. data/data/mod_spox/plugins/Status.rb +28 -0
  41. data/lib/mod_spox/Action.rb +20 -3
  42. data/lib/mod_spox/BaseConfig.rb +1 -0
  43. data/lib/mod_spox/Bot.rb +98 -75
  44. data/lib/mod_spox/BotConfig.rb +14 -6
  45. data/lib/mod_spox/ConfigurationWizard.rb +94 -105
  46. data/lib/mod_spox/Database.rb +33 -13
  47. data/lib/mod_spox/Helpers.rb +67 -38
  48. data/lib/mod_spox/Loader.rb +25 -5
  49. data/lib/mod_spox/Logger.rb +20 -62
  50. data/lib/mod_spox/MessageFactory.rb +34 -25
  51. data/lib/mod_spox/Monitors.rb +5 -0
  52. data/lib/mod_spox/Pipeline.rb +40 -51
  53. data/lib/mod_spox/Plugin.rb +40 -9
  54. data/lib/mod_spox/PluginManager.rb +46 -38
  55. data/lib/mod_spox/Pool.rb +129 -143
  56. data/lib/mod_spox/Socket.rb +41 -50
  57. data/lib/mod_spox/Sockets.rb +211 -0
  58. data/lib/mod_spox/Timer.rb +86 -69
  59. data/lib/mod_spox/handlers/BadNick.rb +1 -1
  60. data/lib/mod_spox/handlers/Created.rb +1 -1
  61. data/lib/mod_spox/handlers/Handler.rb +9 -0
  62. data/lib/mod_spox/handlers/Invite.rb +1 -1
  63. data/lib/mod_spox/handlers/Join.rb +2 -2
  64. data/lib/mod_spox/handlers/Kick.rb +1 -1
  65. data/lib/mod_spox/handlers/LuserChannels.rb +1 -1
  66. data/lib/mod_spox/handlers/LuserOp.rb +1 -1
  67. data/lib/mod_spox/handlers/LuserUnknown.rb +1 -1
  68. data/lib/mod_spox/handlers/Mode.rb +2 -2
  69. data/lib/mod_spox/handlers/MyInfo.rb +1 -1
  70. data/lib/mod_spox/handlers/Names.rb +1 -1
  71. data/lib/mod_spox/handlers/Nick.rb +20 -3
  72. data/lib/mod_spox/handlers/NickInUse.rb +3 -3
  73. data/lib/mod_spox/handlers/Notice.rb +5 -15
  74. data/lib/mod_spox/handlers/Part.rb +1 -1
  75. data/lib/mod_spox/handlers/Ping.rb +1 -1
  76. data/lib/mod_spox/handlers/Pong.rb +1 -1
  77. data/lib/mod_spox/handlers/Privmsg.rb +2 -2
  78. data/lib/mod_spox/handlers/Quit.rb +1 -1
  79. data/lib/mod_spox/handlers/Topic.rb +2 -1
  80. data/lib/mod_spox/handlers/Welcome.rb +3 -3
  81. data/lib/mod_spox/handlers/Who.rb +9 -7
  82. data/lib/mod_spox/handlers/Whois.rb +29 -16
  83. data/lib/mod_spox/handlers/YourHost.rb +1 -1
  84. data/lib/mod_spox/messages/incoming/Privmsg.rb +38 -19
  85. data/lib/mod_spox/messages/internal/DCCListener.rb +12 -0
  86. data/lib/mod_spox/messages/internal/DCCRequest.rb +12 -0
  87. data/lib/mod_spox/messages/internal/DCCSocket.rb +19 -0
  88. data/lib/mod_spox/messages/internal/StatusRequest.rb +2 -1
  89. data/lib/mod_spox/messages/outgoing/Privmsg.rb +21 -5
  90. data/lib/mod_spox/migrations/001_initialize_models.rb +115 -0
  91. data/lib/mod_spox/models/Auth.rb +24 -16
  92. data/lib/mod_spox/models/AuthGroup.rb +4 -3
  93. data/lib/mod_spox/models/Channel.rb +20 -12
  94. data/lib/mod_spox/models/ChannelMode.rb +2 -2
  95. data/lib/mod_spox/models/Config.rb +11 -3
  96. data/lib/mod_spox/models/Group.rb +6 -1
  97. data/lib/mod_spox/models/Nick.rb +93 -33
  98. data/lib/mod_spox/models/NickChannel.rb +8 -6
  99. data/lib/mod_spox/models/NickGroup.rb +16 -0
  100. data/lib/mod_spox/models/NickMode.rb +3 -3
  101. data/lib/mod_spox/models/Server.rb +6 -2
  102. data/lib/mod_spox/models/Setting.rb +12 -6
  103. data/lib/mod_spox/models/Signature.rb +7 -13
  104. data/lib/mod_spox/models/Trigger.rb +1 -1
  105. metadata +125 -100
data/CHANGELOG CHANGED
@@ -1,3 +1,39 @@
1
+ 0.2.0 Release (Beta status)
2
+ Core:
3
+ * Removed support for MySQL and SQLite (SQLite support may be added at a later date)
4
+ * Rebuilt and optimized timer
5
+ * Rebuilt and optimized pooling
6
+ * Fixed authentication bugs
7
+ * Added basic DCC support (still in alpha state)
8
+ * Added daemon support
9
+ * Updated tinyurl helper to use api
10
+ * Updated format_seconds helper
11
+ * Added a format_bytes helper method
12
+ * Fixed PluginManager to handle bad plugins better
13
+ * termios support has been removed
14
+ * Tested for full support on Ruby 1.8 and Ruby 1.9
15
+ * Tested for alpha support on JRuby > 1.1.3
16
+ Plugins:
17
+ * New plugins added:
18
+ * Status - Status and version information from the bot
19
+ * NickServ - Identify with services
20
+ * Twitter - Use twitter via IRC
21
+ * GoogleIt - Will help people unfamiliar with google
22
+ * Slashdot - Last 5 from the Slashdot feed
23
+ * PoolConfig - Configure bot thread pooling
24
+ * RegexTracker - Track regular expressions found in privmsgs
25
+ * TracTicket - Add help tickets to a trac system
26
+ * DCC - Basic DCC chat and file server (alpha state - only works with some clients)
27
+ * AutoRejoin plugin will automatically join channels on connect
28
+ * Confess fixed to use it's own sqlite database. See: http://dev.modspox.com/cgi-bin/trac.cgi/wiki/ConfessSqlite
29
+ * Headers fixed to support http and https plus support for non-standard ports
30
+ * PhpLookup fixed for new manual layout
31
+ * Translate fixed to interact with yahoo properly
32
+ * Karma now has standardized parenthesis usage as well as anti-karma
33
+
34
+ Lots of other fixes throughout. Clean install is recommended. Please read the install
35
+ guide for an overview of what information you will need and what setup is required.
36
+
1
37
  0.1.0.1 Release (Bug fix)
2
38
  * Fix made to work with sequel 2.2
3
39
 
data/INSTALL CHANGED
@@ -5,11 +5,11 @@ gem install --include-dependencies mod_spox
5
5
  Requirements include:
6
6
  * sequel
7
7
  * database driver
8
- * Ruby >= 1.8.4
8
+ * Ruby >= 1.8.6
9
9
 
10
10
  Optional:
11
11
  * fastthread
12
12
  * termios
13
13
 
14
14
  More detailed information can be found at:
15
- http://dev.modspox.com/cgi-bin/trac.cgi/wiki/InstallHowto
15
+ http://dev.modspox.com/cgi-bin/trac.cgi/wiki/InstallHowto
data/README CHANGED
@@ -23,7 +23,6 @@ mod_spox
23
23
 
24
24
  == Optional
25
25
 
26
- * termios
27
26
  * fastthread
28
27
 
29
28
  == Install
data/bin/mod_spox CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  ## include our needed libraries ##
4
4
 
5
- ['rubygems', 'sequel', 'thread', 'etc', 'getoptlong'].each{|file|
5
+ ['rubygems', 'sequel', 'thread', 'etc', 'getoptlong', 'logger'].each do |file|
6
6
  begin
7
7
  require file
8
8
  rescue Object => boom
9
9
  puts "ERROR: Failed to load required library: #{file}"
10
10
  exit 1
11
11
  end
12
- }
12
+ end
13
13
 
14
14
  ## optional libraries ##
15
15
  begin
@@ -18,15 +18,21 @@ rescue Object => boom
18
18
  # ignore if not found #
19
19
  end
20
20
 
21
- $BOTVERSION='0.1.0.1'
21
+ $BOTVERSION='0.2.0'
22
+ $BOTCODENAME='avocado'
22
23
  $VERBOSITY = 0
23
24
  $MOD_SPOX_PATH = nil
25
+ $DAEMON_BOT = false
26
+ $LOGTO = $stdout
27
+ $LOGLEVEL = :fatal
28
+ $JDBC = false
29
+
24
30
  Sequel::Model.unrestrict_primary_key
25
31
 
26
32
  begin
27
33
  require 'mod_spox/Loader'
28
34
  rescue
29
- p 'ERROR: Failed to load mod_spox'
35
+ puts 'ERROR: Failed to load mod_spox'
30
36
  exit 1
31
37
  end
32
38
  include ModSpox
@@ -34,40 +40,73 @@ include ModSpox
34
40
  opts = GetoptLong.new(
35
41
  ['--config', '-c', GetoptLong::NO_ARGUMENT],
36
42
  ['--debug', '-d', GetoptLong::OPTIONAL_ARGUMENT],
43
+ ['--verbosity', '-V', GetoptLong::OPTIONAL_ARGUMENT],
37
44
  ['--version', '-v', GetoptLong::NO_ARGUMENT],
45
+ ['--jdbc', '-j', GetoptLong::NO_ARGUMENT],
38
46
  ['--help', '-h', GetoptLong::NO_ARGUMENT],
39
- ['--path', '-p', GetoptLong::REQUIRED_ARGUMENT]
47
+ ['--path', '-p', GetoptLong::REQUIRED_ARGUMENT],
48
+ ['--daemon', '-D', GetoptLong::NO_ARGUMENT]
40
49
  )
41
50
  verbose = 0
42
51
  opts.each do |opt, arg|
43
52
  case opt
44
53
  when '--help'
45
54
  puts 'Usage: mod_spox [opts]'
46
- puts '--config -c: starts configuration wizard'
47
- puts '--debug -d: turns on debugging (include number >0 for more info)'
48
- puts '--version -v: output bot version information'
49
- puts '--help -h: print this help message'
55
+ puts '--config -c: starts configuration wizard'
56
+ puts '--path -p /config/path path to configuration directory'
57
+ puts '--jdbc -j use jdbc database driver (jruby)'
58
+ puts '--debug -d [logfile]: turns on debugging and outputs to file (default STDOUT)'
59
+ puts '--verbosity -V [(info|warn|fatal)]: verbosity of debug output (default fatal)'
60
+ puts '--deamon -D: daemonizes the process'
61
+ puts '--version -v: output bot version information'
62
+ puts '--help -h: print this help message'
50
63
  exit
51
64
  when '--version'
52
65
  puts "mod_spox IRC bot version: #{$BOTVERSION}"
53
66
  puts 'http://rubyforge.org/projects/modspox'
54
67
  exit
68
+ when '--jdbc'
69
+ $JDBC = true
70
+ begin
71
+ require 'jdbc/postgres'
72
+ rescue Object => boom
73
+ puts 'Failed to load JDBC Postgres gem'
74
+ exit 1
75
+ end
55
76
  when '--debug'
56
- if(arg && arg =~ /^[0-9]+/)
57
- $VERBOSITY = arg.to_i
77
+ if(arg && File.writable?(arg))
78
+ $LOGTO = arg
79
+ else
80
+ $LOGTO = $stdout
58
81
  end
59
82
  when '--config'
60
83
  require 'mod_spox/ConfigurationWizard'
61
84
  wizard = ConfigurationWizard.new
62
- wizard.run
85
+ BotConfig.configured? ? wizard.update : wizard.run
63
86
  exit
64
87
  when '--path'
65
88
  $MOD_SPOX_PATH = arg
89
+ when '--daemon'
90
+ begin
91
+ $DAEMON_BOT = true
92
+ require 'daemons'
93
+ rescue Object => boom
94
+ puts 'Error: You must install the Daemons gem: (http://daemons.rubyforge.org)'
95
+ exit 1
96
+ end
97
+ when '--verbosity'
98
+ if(arg && arg =~ /^(info|warn|fatal)$/)
99
+ $LOGLEVEL = arg.to_sym
100
+ end
66
101
  end
67
102
  end
68
103
 
69
104
  initialize_bot
70
105
  require 'mod_spox/Bot'
71
106
 
107
+ if($DAEMON_BOT)
108
+ Daemonize.daemonize(nil, 'mod_spox')
109
+ end
110
+
72
111
  bot = Bot.new
73
112
  bot.run
@@ -1,7 +1,7 @@
1
1
  class AOLSpeak < ModSpox::Plugin
2
2
 
3
3
  include Models
4
-
4
+
5
5
  def initialize(pipeline)
6
6
  super
7
7
  group = Group.find_or_create(:name => 'banner')
@@ -9,20 +9,13 @@ class AOLSpeak < ModSpox::Plugin
9
9
  Signature.find_or_create(:signature => 'aolkick (\S+) ?(\S+)?', :plugin => name, :method => 'aolkick', :description => 'AOL speak kick',
10
10
  :group_id => group.pk).params = [:nick, :channel]
11
11
  build_aolspeak
12
- @banner = nil
13
- @pipeline.hook(self, :banner_watch, :Internal_PluginResponse)
14
- @pipeline << Messages::Internal::PluginRequest.new(self, 'Banner')
15
12
  end
16
-
13
+
17
14
  def aolspeak(message, params)
18
15
  reply message.replyto, @aolspeak[rand(@aolspeak.size) - 1]
19
16
  end
20
-
17
+
21
18
  def aolkick(message, params)
22
- if(@banner.nil?)
23
- @pipeline << Messages::Internal::PluginRequest.new(self, 'Banner')
24
- sleep(0.1)
25
- end
26
19
  if(params[:channel])
27
20
  channel = Models::Channel.filter(:name => params[:channel]).first
28
21
  else
@@ -30,21 +23,15 @@ class AOLSpeak < ModSpox::Plugin
30
23
  end
31
24
  nick = Helpers.find_model(params[:nick], false)
32
25
  if(channel && nick)
33
- @banner.plugin.ban(nick, channel, 60, @aolspeak[rand(@aolspeak.size) - 1], invite=false, show_time=false)
26
+ @pipeline << plugin_const(:Banner_Ban).new(nick, channel, :kickban, @aolspeak[rand(@aolspeak.size) - 1], 60, false, false)
34
27
  else
35
28
  reply message.replyto, "\2Error:\2 Failed to find channel: #{params[:channel]}" unless channel
36
29
  reply message.replyto, "\2Error:\2 Failed to find nick: #{params[:nick]}" unless nick
37
30
  end
38
31
  end
39
32
 
40
- def banner_watch(message)
41
- if(message.origin == self && message.found?)
42
- @banner = message.plugin
43
- end
44
- end
45
-
46
33
  private
47
-
34
+
48
35
  def build_aolspeak
49
36
  @aolspeak = [
50
37
  'ALL OREAND THE GIFCHERRY BUSH DA BOON CHASED DA WHEASELGIFPASTECLITNUGGET SHIT]',
@@ -16,15 +16,13 @@ class AutoKick < ModSpox::Plugin
16
16
  :group_id => group.pk, :description => 'Remove an autokick rule').params = [:id]
17
17
  Signature.find_or_create(:signature => 'autokick colors ?(on|off)?', :plugin => name, :method => 'colors',
18
18
  :group_id => group.pk, :description => 'Kick user for using colors', :requirement => 'public').params = [:action]
19
- @pipeline.hook(self, :banner_watch, :Internal_PluginResponse)
20
- @banner = nil
21
19
  @map = nil
22
20
  @colors = Setting[:colorkick]
23
- @colors = Array.new if @colors.nil?
21
+ @colors = Array.new unless @colors.is_a?(Array)
24
22
  AutoKickRecord.create_table unless AutoKickRecord.table_exists?
25
23
  do_listen
26
24
  end
27
-
25
+
28
26
  def colors(message, params)
29
27
  if(params[:action])
30
28
  if(params[:action] == 'on')
@@ -32,12 +30,16 @@ class AutoKick < ModSpox::Plugin
32
30
  reply message.replyto, 'Colored autokick is already enabled'
33
31
  else
34
32
  @colors << message.target.pk
35
- Setting[:colorkick] = @colors
33
+ record = Setting.find_or_create(:name => 'colorkick')
34
+ record.value = @colors
35
+ record.save
36
36
  reply message.replyto, 'Colored autokick has been enabled'
37
37
  end
38
38
  else
39
39
  @colors.delete(message.target.pk)
40
- Setting[:colorkick] = @colors
40
+ record = Setting.find_or_create(:name => 'colorkick')
41
+ record.value = @colors
42
+ record.save
41
43
  reply message.replyto, 'Colored autokick has been disabled'
42
44
  end
43
45
  else
@@ -45,7 +47,7 @@ class AutoKick < ModSpox::Plugin
45
47
  reply message.replyto, "Colored autokick is currently \2#{status}\2"
46
48
  end
47
49
  end
48
-
50
+
49
51
  def list(message, params)
50
52
  records = AutoKickRecord.all
51
53
  unless(records.empty?)
@@ -56,7 +58,7 @@ class AutoKick < ModSpox::Plugin
56
58
  reply message.replyto, 'No rules currently enabled'
57
59
  end
58
60
  end
59
-
61
+
60
62
  def add(message, params)
61
63
  if(params[:channel])
62
64
  channel = Channel.filter(:name => params[:channel]).first
@@ -71,7 +73,7 @@ class AutoKick < ModSpox::Plugin
71
73
  reply message.replyto, "\2Error:\2 I have no record of #{params[:channel]}. Failed to add autokick rule."
72
74
  end
73
75
  end
74
-
76
+
75
77
  def remove(message, params)
76
78
  record = AutoKickRecord[params[:id].to_i]
77
79
  if(record)
@@ -82,32 +84,33 @@ class AutoKick < ModSpox::Plugin
82
84
  reply message.replyto, "\2Error:\2 Failed to find an autokick rule with ID: #{params[:id]}"
83
85
  end
84
86
  end
85
-
87
+
86
88
  def listener(message)
89
+ return unless message.is_public?
87
90
  if(@map.keys.include?(message.target.pk))
91
+ bmessage = nil
92
+ btime = 0
88
93
  @map[message.target.pk].each do |pattern|
89
94
  reg = Regexp.new(pattern, Regexp::IGNORECASE)
90
95
  unless(reg.match(message.message).nil?)
91
96
  record = AutoKickRecord.filter(:pattern => pattern).first
92
- @banner.plugin.ban(message.source, message.target, record.bantime, record.message, false, true)
97
+ bmessage = record.message
98
+ btime += record.bantime
93
99
  end
94
- end
100
+ end
101
+ unless(bmessage.nil?)
102
+ @pipeline << plugin_const(:Banner_Ban).new(message.source, message.target, :kickban, bmessage, btime, false, true)
103
+ end
95
104
  end
96
105
  if(@colors.include?(message.target.pk))
97
106
  if(message.is_colored?)
98
- @banner.plugin.ban(message.source, message.target, 60, 'No color codes allowed', false, true)
107
+ @pipeline << plugin_const(:Banner_Ban).new(message.source, message.target, :kickban, 'No color codes allowed', 60, false, true)
99
108
  end
100
109
  end
101
110
  end
102
-
103
- def banner_watch(message)
104
- if(message.origin == self && message.found?)
105
- @banner = message.plugin
106
- end
107
- end
108
-
111
+
109
112
  private
110
-
113
+
111
114
  def do_listen
112
115
  @map = nil
113
116
  begin
@@ -122,11 +125,10 @@ class AutoKick < ModSpox::Plugin
122
125
  @map[record.channel_id] = [] unless @map[record.channel_id]
123
126
  @map[record.channel_id] << record.pattern
124
127
  end
125
- @pipeline << Messages::Internal::PluginRequest.new(self, 'Banner')
126
128
  @pipeline.hook(self, :listener, :Incoming_Privmsg)
127
129
  end
128
130
  end
129
-
131
+
130
132
  class AutoKickRecord < Sequel::Model
131
133
  set_schema do
132
134
  primary_key :id
@@ -135,6 +137,25 @@ class AutoKick < ModSpox::Plugin
135
137
  text :message, :null => false
136
138
  foreign_key :channel_id, :table => :channels
137
139
  end
140
+
141
+ def channel
142
+ ModSpox::Models::Channel[channel_id]
143
+ end
144
+ end
145
+
146
+ class AutoKickPersonal < Sequel::Model
147
+ set_schema do
148
+ primary_key :id
149
+ varchar :pattern, :default => nil
150
+ integer :bantime, :null => false, :default => 60
151
+ varchar :message, :null => false
152
+ foreign_key :nick_id, :table => :nicks
153
+ foreign_key :channel_id, :table => :channels
154
+ end
155
+
156
+ def nick
157
+ ModSpox::Models::Nick[nick_id]
158
+ end
138
159
 
139
160
  def channel
140
161
  ModSpox::Models::Channel[channel_id]
@@ -54,11 +54,8 @@ class AutoMode < ModSpox::Plugin
54
54
  end
55
55
 
56
56
  def voice(m, p)
57
- record = ModeRecord.filter(:nick_id => m.source.pk, :channel_id => m.target.pk).first
58
- if(record && record.voice)
59
- @pipeline << Messages::Outgoing::ChannelMode.new(m.target, '+v', m.source.nick) if me.is_op?(m.target)
60
- else
61
- reply m.replyto, "\2Error:\2 You are not listed on the auto-voice list"
57
+ ModeRecord.filter(:nick_id => m.source.pk, :channel_id => m.target.pk).each do |record|
58
+ @pipeline << Messages::Outgoing::ChannelMode.new(m.target, '+v', m.source.nick) if me.is_op?(m.target) && record.voice
62
59
  end
63
60
  end
64
61
 
@@ -3,6 +3,9 @@ class AutoRejoin < ModSpox::Plugin
3
3
  def initialize(pipeline)
4
4
  super
5
5
  @pipeline.hook(self, :check_kick, :Incoming_Kick)
6
+ @pipeline.hook(self, :check_join, :Incoming_Join)
7
+ @pipeline.hook(self, :check_part, :Incoming_Part)
8
+ @pipeline.hook(self, :do_joins, :Incoming_Welcome)
6
9
  end
7
10
 
8
11
  def check_kick(message)
@@ -10,5 +13,23 @@ class AutoRejoin < ModSpox::Plugin
10
13
  @pipeline << Messages::Outgoing::Join.new(message.channel)
11
14
  end
12
15
  end
16
+
17
+ def check_join(m)
18
+ if(m.nick == me)
19
+ m.channel.update(:autojoin => true)
20
+ end
21
+ end
22
+
23
+ def check_part(m)
24
+ if(m.nick == me)
25
+ m.channel.update(:autojoin => false)
26
+ end
27
+ end
28
+
29
+ def do_joins(m)
30
+ Models::Channel.filter(:autojoin => true).each do |channel|
31
+ @pipeline << Messages::Outgoing::Join.new(channel)
32
+ end
33
+ end
13
34
 
14
35
  end
@@ -28,7 +28,7 @@ class Bouncer < ModSpox::Plugin
28
28
 
29
29
  def get_msgs(message)
30
30
  unless(@clients.empty?)
31
- Logger.log("BOUNCER: Sending to #{@clients.size} clients")
31
+ Logger.info("BOUNCER: Sending to #{@clients.size} clients")
32
32
  @clients.each do |client|
33
33
  begin
34
34
  if(message.raw_content.is_a?(Array))
@@ -107,18 +107,18 @@ class Bouncer < ModSpox::Plugin
107
107
  until(@socket.closed?)
108
108
  begin
109
109
  new_con = @socket.accept_nonblock
110
- Logger.log("BOUNCER: New connection established on bouncer")
110
+ Logger.info("BOUNCER: New connection established on bouncer")
111
111
  @clients << {
112
112
  :connection => new_con,
113
113
  :thread => Thread.new(new_con) do | con |
114
114
  begin
115
- Logger.log("CONNECTION: #{con}")
115
+ Logger.info("CONNECTION: #{con}")
116
116
  until(con.closed?)
117
- Logger.log("WAITING FOR STUFF ON :#{con}")
117
+ Logger.info("WAITING FOR STUFF ON :#{con}")
118
118
  Kernel.select([con], nil, nil, nil)
119
- Logger.log("Woken up and ready to read")
119
+ Logger.info("Woken up and ready to read")
120
120
  string = con.gets
121
- Logger.log("BOUNCER GOT MESSAGE: #{string}")
121
+ Logger.info("BOUNCER GOT MESSAGE: #{string}")
122
122
  if(string.empty?)
123
123
  raise Exception.new("EMPTY STRING")
124
124
  else
@@ -126,7 +126,7 @@ class Bouncer < ModSpox::Plugin
126
126
  end
127
127
  end
128
128
  rescue Object => boom
129
- Logger.log("THREAD BOUNCER ERROR: #{boom}")
129
+ Logger.warn("THREAD BOUNCER ERROR: #{boom}")
130
130
  end
131
131
  end
132
132
  }
@@ -139,7 +139,7 @@ class Bouncer < ModSpox::Plugin
139
139
  end
140
140
  start_processor
141
141
  else
142
- Logger.log("Error: Bouncer was not started. Failed to find set port number")
142
+ Logger.warn("Error: Bouncer was not started. Failed to find set port number")
143
143
  end
144
144
  end
145
145
 
@@ -158,7 +158,7 @@ class Bouncer < ModSpox::Plugin
158
158
  begin
159
159
  while(@listener) do
160
160
  info = @to_server.pop
161
- Logger.log("Processing message: #{info[:message]}")
161
+ Logger.info("Processing message: #{info[:message]}")
162
162
  if(info[:message] =~ /^USER\s/i)
163
163
  initialize_connection(info[:socket])
164
164
  else
@@ -166,7 +166,7 @@ class Bouncer < ModSpox::Plugin
166
166
  end
167
167
  end
168
168
  rescue Object => boom
169
- Logger.log("BOUNCER ERROR: #{boom}")
169
+ Logger.warn("BOUNCER ERROR: #{boom}")
170
170
  unless(@clients.empty?)
171
171
  @clients.each do |socket|
172
172
  socket[:connection].close
@@ -0,0 +1,12 @@
1
+ class Bytes < ModSpox::Plugin
2
+ include Models
3
+ def initialize(args)
4
+ super
5
+ Signature.find_or_create(:signature => 'bytes (\d+)', :plugin => name, :method => 'convert',
6
+ :description => 'Convert bytes to human readable string').params = [:bytes]
7
+ end
8
+
9
+ def convert(message, params)
10
+ reply message.replyto, "#{params[:bytes]} is roughly #{Helpers.format_size(params[:bytes].to_i)}"
11
+ end
12
+ end