rbot 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +8 -0
- data/ChangeLog +51 -0
- data/INSTALL +4 -0
- data/README +1 -0
- data/REQUIREMENTS +11 -0
- data/TODO +2 -0
- data/bin/rbot +21 -2
- data/data/rbot/languages/german.lang +4 -1
- data/data/rbot/languages/russian.lang +75 -0
- data/data/rbot/plugins/autoop.rb +42 -51
- data/data/rbot/plugins/bans.rb +205 -0
- data/data/rbot/plugins/bash.rb +56 -0
- data/data/rbot/plugins/chucknorris.rb +74 -0
- data/data/rbot/plugins/chucknorris.yml.gz +0 -0
- data/data/rbot/plugins/deepthoughts.rb +95 -0
- data/data/rbot/plugins/demauro.rb +95 -0
- data/data/rbot/plugins/digg.rb +51 -0
- data/data/rbot/plugins/figlet.rb +24 -0
- data/data/rbot/plugins/forecast.rb +133 -0
- data/data/rbot/plugins/freshmeat.rb +13 -7
- data/data/rbot/plugins/google.rb +2 -0
- data/data/rbot/plugins/grouphug.rb +36 -0
- data/data/rbot/plugins/imdb.rb +92 -0
- data/data/rbot/plugins/insult.rb +8 -1
- data/data/rbot/plugins/iplookup.rb +227 -0
- data/data/rbot/plugins/karma.rb +2 -2
- data/data/rbot/plugins/keywords.rb +470 -0
- data/data/rbot/plugins/lart.rb +132 -146
- data/data/rbot/plugins/lastfm.rb +25 -0
- data/data/rbot/plugins/markov.rb +204 -0
- data/data/rbot/plugins/math.rb +5 -1
- data/data/rbot/plugins/nickserv.rb +71 -11
- data/data/rbot/plugins/opme.rb +19 -19
- data/data/rbot/plugins/quakeauth.rb +2 -2
- data/data/rbot/plugins/quotes.rb +40 -25
- data/data/rbot/plugins/remind.rb +1 -1
- data/data/rbot/plugins/rot13.rb +2 -2
- data/data/rbot/plugins/roulette.rb +49 -15
- data/data/rbot/plugins/rss.rb +585 -0
- data/data/rbot/plugins/rubyurl.rb +39 -0
- data/data/rbot/plugins/seen.rb +2 -1
- data/data/rbot/plugins/slashdot.rb +5 -5
- data/data/rbot/plugins/spell.rb +5 -0
- data/data/rbot/plugins/theyfightcrime.rb +121 -0
- data/data/rbot/plugins/threat.rb +55 -0
- data/data/rbot/plugins/tinyurl.rb +39 -0
- data/data/rbot/plugins/topic.rb +204 -0
- data/data/rbot/plugins/urban.rb +71 -0
- data/data/rbot/plugins/url.rb +399 -4
- data/data/rbot/plugins/wow.rb +123 -0
- data/data/rbot/plugins/wserver.rb +1 -1
- data/data/rbot/templates/levels.rbot +2 -0
- data/lib/rbot/auth.rb +207 -96
- data/lib/rbot/channel.rb +5 -5
- data/lib/rbot/config.rb +125 -24
- data/lib/rbot/dbhash.rb +87 -21
- data/lib/rbot/httputil.rb +181 -13
- data/lib/rbot/ircbot.rb +525 -179
- data/lib/rbot/ircsocket.rb +330 -54
- data/lib/rbot/message.rb +66 -23
- data/lib/rbot/messagemapper.rb +25 -17
- data/lib/rbot/plugins.rb +244 -115
- data/lib/rbot/post-clean.rb +1 -0
- data/lib/rbot/{post-install.rb → post-config.rb} +1 -1
- data/lib/rbot/rbotconfig.rb +29 -14
- data/lib/rbot/registry.rb +111 -72
- data/lib/rbot/rfc2812.rb +208 -197
- data/lib/rbot/timer.rb +4 -0
- data/lib/rbot/utils.rb +2 -2
- metadata +127 -104
- data/data/rbot/plugins/rss.rb.disabled +0 -414
- data/lib/rbot/keywords.rb +0 -433
data/AUTHORS
CHANGED
@@ -1,14 +1,22 @@
|
|
1
1
|
Main Author
|
2
2
|
o Tom Gilbert (giblet) <tom@linuxbrit.co.uk>
|
3
3
|
|
4
|
+
Bugbear (heavy-duty framework reworker and backwards-compatibility-breaker)
|
5
|
+
o Giuseppe Bilotta (tango_) <giuseppe.bilotta@gmail.com>
|
6
|
+
|
4
7
|
Patch contributors
|
5
8
|
o Peter Suschlik (pesu) <peter@zilium.de>
|
9
|
+
o Alexey I. Froloff <raorn@altlinux.ru>
|
10
|
+
o Ari Pollak <ajp@aripollak.com>
|
11
|
+
o Rudolf Polzer <atfield-dt@durchnull.de>
|
12
|
+
o Ren� Nussbaumer <public@killerfox.forkbomb.ch>
|
6
13
|
|
7
14
|
Module contributors
|
8
15
|
o dice.rb - David Dorward (Dorward) <david@david.us-lot.org>
|
9
16
|
o lart.rb - Michael Brailsford <brailsmt@yahoo.com>
|
10
17
|
o stats.rb - Michael Brailsford <brailsmt@yahoo.com>
|
11
18
|
o ri.rb - Michael Brailsford <brailsmt@yahoo.com>
|
19
|
+
o bash/threat - Robin Kearney <robin@riviera.org.uk>
|
12
20
|
|
13
21
|
"Testing" (having fun breaking rbot creatively)
|
14
22
|
o Paul Duncan (pabs) <pabs@pablotron.org>
|
data/ChangeLog
CHANGED
@@ -1,3 +1,54 @@
|
|
1
|
+
Wed Sep 07 20:16:46 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
|
2
|
+
|
3
|
+
* Fixed quit, broke it last commit
|
4
|
+
* Fixed trap() for win32
|
5
|
+
|
6
|
+
Sun Aug 21 13:29:55 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
|
7
|
+
|
8
|
+
* fix for bug in quakenet plugin (trac #14)
|
9
|
+
* multiple fixes for unescaped bot nick in regexp's (trac #13)
|
10
|
+
|
11
|
+
Fri Aug 12 20:51:38 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
|
12
|
+
|
13
|
+
* fix up autoop plugin a bit
|
14
|
+
|
15
|
+
Thu Aug 11 00:13:11 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
|
16
|
+
|
17
|
+
* Added two plugins from Robin Kearney <robin@riviera.org.uk>
|
18
|
+
* Threat (US threat level :P)
|
19
|
+
* bash (bash.org quotes)
|
20
|
+
|
21
|
+
Thu Aug 11 00:04:31 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
|
22
|
+
|
23
|
+
* Patches from "Alexey I. Froloff" <raorn@altlinux.ru>
|
24
|
+
* Do not use "/home/#{Etc.getlogin}/" for default home directory, use
|
25
|
+
"#{Etc.getpwnam(Etc.getlogin).dir}/" instead.
|
26
|
+
* Do not try to load same plugin from different locations. Added ability
|
27
|
+
to disable system-wide plugins - create PLUGIN.rb.disabled in user's
|
28
|
+
plugins directory.
|
29
|
+
* For example, to disable freshmeat plugin installed in /usr/share/rbot/plugins/freshmeat.rb one can create empty file ~/.rbot/plugins/freshmeat.rb.disabled
|
30
|
+
|
31
|
+
Mon Aug 08 23:08:01 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
|
32
|
+
|
33
|
+
* new markov plugin for random inane chat
|
34
|
+
|
35
|
+
Sun Aug 07 18:20:24 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
|
36
|
+
|
37
|
+
* stop insult plugin being used to insult the bot
|
38
|
+
|
39
|
+
Sun Aug 07 17:53:06 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
|
40
|
+
|
41
|
+
* workaround for people without YAML::load_file
|
42
|
+
* quit message for restart
|
43
|
+
|
44
|
+
Sun Aug 07 15:11:07 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
|
45
|
+
|
46
|
+
* fix address_prefix, broken in 0.9.9, reported by ruskie.
|
47
|
+
|
48
|
+
Sat Aug 06 00:54:34 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
|
49
|
+
|
50
|
+
* Released 0.9.9
|
51
|
+
|
1
52
|
Fri Aug 05 23:55:20 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
|
2
53
|
|
3
54
|
* few more tweaks preparing to release 0.9.9
|
data/INSTALL
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
Run setup.rb to install the bot.
|
2
|
+
|
1
3
|
Just run rbot, it'll ask you for any core information it needs before it can
|
2
4
|
start, after that you can configure everything else online using the config
|
3
5
|
module.
|
@@ -6,3 +8,5 @@ You can maintain multiple configurations at once. Start rbot with the
|
|
6
8
|
location you want it to store runtime data in. By default, running rbot
|
7
9
|
uses the ~/.rbot config directory. If you run 'rbot /path/to/foo', then the
|
8
10
|
configuration will be stored to and read from there instead.
|
11
|
+
|
12
|
+
Instructions for windows in REQUIREMENTS
|
data/README
CHANGED
data/REQUIREMENTS
CHANGED
@@ -9,6 +9,8 @@ Core requirements
|
|
9
9
|
socket
|
10
10
|
uri
|
11
11
|
|
12
|
+
(for debian, you'll also need libopenssl-ruby)
|
13
|
+
|
12
14
|
Plugin requirements
|
13
15
|
(these are all optional, if you don't have them, the plugins just won't
|
14
16
|
function)
|
@@ -32,3 +34,12 @@ spell plugin:
|
|
32
34
|
ispell(1)
|
33
35
|
|
34
36
|
|
37
|
+
Running rbot on win32
|
38
|
+
=====================
|
39
|
+
|
40
|
+
here is bdb:
|
41
|
+
http://ftp.ruby-lang.org/pub/ruby/binaries/mingw/1.8/ext/bdb-0.5.1-i386-mingw32-1.8.tar.gz
|
42
|
+
|
43
|
+
and you need the Win32 MinGW version of Ruby:
|
44
|
+
http://ftp.ruby-lang.org/pub/ruby/binaries/mingw/1.8/ruby-1.8.4-i386-mingw32.tar.gz
|
45
|
+
|
data/TODO
CHANGED
data/bin/rbot
CHANGED
@@ -21,30 +21,39 @@
|
|
21
21
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
22
22
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
23
|
|
24
|
+
$KCODE = 'u'
|
25
|
+
|
24
26
|
$VERBOSE=true
|
25
27
|
|
26
28
|
require 'etc'
|
27
29
|
require 'getoptlong'
|
28
30
|
require 'fileutils'
|
29
31
|
|
30
|
-
$version="0.9.
|
32
|
+
$version="0.9.10"
|
31
33
|
$opts = Hash.new
|
32
34
|
|
33
35
|
orig_opts = ARGV.dup
|
34
36
|
|
35
37
|
opts = GetoptLong.new(
|
38
|
+
["--background", "-b", GetoptLong::NO_ARGUMENT],
|
36
39
|
["--debug", "-d", GetoptLong::NO_ARGUMENT],
|
37
40
|
["--help", "-h", GetoptLong::NO_ARGUMENT],
|
41
|
+
["--loglevel", "-l", GetoptLong::REQUIRED_ARGUMENT],
|
38
42
|
["--trace", "-t", GetoptLong::REQUIRED_ARGUMENT],
|
39
43
|
["--version", "-v", GetoptLong::NO_ARGUMENT]
|
40
44
|
)
|
41
45
|
|
42
46
|
$debug = false
|
47
|
+
$daemonize = false
|
48
|
+
|
43
49
|
opts.each {|opt, arg|
|
44
50
|
$debug = true if(opt == "--debug")
|
51
|
+
$daemonize = true if(opt == "--background")
|
45
52
|
$opts[opt.sub(/^-+/, "")] = arg
|
46
53
|
}
|
47
54
|
|
55
|
+
$cl_loglevel = $opts["loglevel"].to_i
|
56
|
+
|
48
57
|
if ($opts["trace"])
|
49
58
|
set_trace_func proc { |event, file, line, id, binding, classname|
|
50
59
|
if classname.to_s == $opts["trace"]
|
@@ -53,10 +62,19 @@ if ($opts["trace"])
|
|
53
62
|
}
|
54
63
|
end
|
55
64
|
|
65
|
+
defaultlib = File.expand_path(File.dirname($0) + '/../lib')
|
66
|
+
|
67
|
+
if File.directory? "#{defaultlib}/rbot"
|
68
|
+
unless $:.include? defaultlib
|
69
|
+
$:.unshift defaultlib
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
56
73
|
begin
|
57
74
|
require 'rbot/ircbot'
|
58
75
|
rescue LoadError => e
|
59
|
-
puts "Error: couldn't find the rbot/ircbot module
|
76
|
+
puts "Error: couldn't find the rbot/ircbot module (or one of its dependencies)\n"
|
77
|
+
puts e
|
60
78
|
exit 2
|
61
79
|
end
|
62
80
|
|
@@ -70,6 +88,7 @@ if ($opts["help"])
|
|
70
88
|
puts " -h, --help this message"
|
71
89
|
puts " -v, --version version information"
|
72
90
|
puts " -d, --debug enable debug messages"
|
91
|
+
puts " -b, --background background (daemonize) the bot"
|
73
92
|
puts "config directory defaults to ~/.rbot"
|
74
93
|
exit 0
|
75
94
|
end
|
@@ -19,7 +19,8 @@ dunno:
|
|
19
19
|
ich kann es nicht tun
|
20
20
|
am besten du schaust selber nach
|
21
21
|
dunno_about_X:
|
22
|
-
ich weiss nichts
|
22
|
+
ich weiss nichts �ber %s
|
23
|
+
ich habe nie von %s geh�rt :(
|
23
24
|
was zum Teufel ist %s?
|
24
25
|
insult:
|
25
26
|
%s: Arsch!
|
@@ -55,12 +56,14 @@ welcome:
|
|
55
56
|
np :)
|
56
57
|
thanks:
|
57
58
|
Danke :)
|
59
|
+
S�ss!
|
58
60
|
juhu :)
|
59
61
|
:-D
|
60
62
|
Prost!
|
61
63
|
thanks_X:
|
62
64
|
%s: danke :)
|
63
65
|
%s: :-D
|
66
|
+
%s: s�ss!
|
64
67
|
%s: juhu :)
|
65
68
|
%s: Prost
|
66
69
|
quit:
|
@@ -0,0 +1,75 @@
|
|
1
|
+
okay:
|
2
|
+
������
|
3
|
+
�������
|
4
|
+
�� �������
|
5
|
+
��� �������
|
6
|
+
�������
|
7
|
+
�����
|
8
|
+
����������
|
9
|
+
�� ��
|
10
|
+
�������
|
11
|
+
��� �������
|
12
|
+
dunno:
|
13
|
+
������
|
14
|
+
������� �� ����
|
15
|
+
��� �������
|
16
|
+
� �� ���� ��� ������
|
17
|
+
���?
|
18
|
+
���� �� � ����
|
19
|
+
�� ���������
|
20
|
+
� ��� ��� �����
|
21
|
+
� �� �������?
|
22
|
+
�� ���!
|
23
|
+
dunno_about_X:
|
24
|
+
������ �� %s
|
25
|
+
������� �� ������ %s :(
|
26
|
+
%s? � ��� ��� ����� ?
|
27
|
+
�� ��� ������ %s?
|
28
|
+
insult:
|
29
|
+
%s: � ��� ��������!
|
30
|
+
%s: :(
|
31
|
+
%s: � ��� ��� ������� :(
|
32
|
+
%s: ����!
|
33
|
+
%s: � ���� ���������
|
34
|
+
%s: � �� ���� �������
|
35
|
+
hello:
|
36
|
+
������ :)
|
37
|
+
��� ���� :)
|
38
|
+
������
|
39
|
+
�� ���!
|
40
|
+
���� ������
|
41
|
+
������ ����
|
42
|
+
������ ����
|
43
|
+
��� ����?
|
44
|
+
hello_X:
|
45
|
+
������ %s :)
|
46
|
+
%s: ������
|
47
|
+
%s: ���� ������
|
48
|
+
%s: ������ ����
|
49
|
+
hey %s :)
|
50
|
+
%s: �� ���!
|
51
|
+
%s: ��� �� ���
|
52
|
+
��� ������ %s!
|
53
|
+
%s: ���!
|
54
|
+
����������� %s?
|
55
|
+
welcome:
|
56
|
+
��� �������
|
57
|
+
������ ���
|
58
|
+
��� ���� �������
|
59
|
+
��� ������
|
60
|
+
:)
|
61
|
+
thanks:
|
62
|
+
������ :)
|
63
|
+
�� ��� ������!
|
64
|
+
������� :)
|
65
|
+
=D
|
66
|
+
� �� ������!
|
67
|
+
thanks_X:
|
68
|
+
%s: ������� :)
|
69
|
+
%s: �� ��� ������!!
|
70
|
+
%s: =D
|
71
|
+
%s: ������ :)
|
72
|
+
%s: � �� ������
|
73
|
+
quit:
|
74
|
+
�� ��������
|
75
|
+
�� � �����
|
data/data/rbot/plugins/autoop.rb
CHANGED
@@ -1,68 +1,59 @@
|
|
1
1
|
class AutoOP < Plugin
|
2
|
-
@@handlers = {
|
3
|
-
"addop" => "handle_addop",
|
4
|
-
"rmop" => "handle_rmop",
|
5
|
-
"listop" => "handle_listop"
|
6
|
-
}
|
7
|
-
|
8
2
|
def help(plugin, topic="")
|
9
|
-
"perform autoop based on hostmask - usage:
|
3
|
+
"perform autoop based on hostmask - usage: add <hostmask> [channel channel ...], rm <hostmask> [channel], list - list current ops. If you don't specify which channels, all channels are assumed"
|
10
4
|
end
|
11
5
|
|
12
6
|
def join(m)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def privmsg(m)
|
23
|
-
if(m.private?)
|
24
|
-
if (!m.params || m.params == "list")
|
25
|
-
handle_listop(m)
|
26
|
-
elsif (m.params =~ /^add\s+(.+)$/)
|
27
|
-
handle_addop(m, $1)
|
28
|
-
elsif (m.params =~ /^rm\s+(.+)$/)
|
29
|
-
handle_rmop(m, $1)
|
30
|
-
end
|
7
|
+
return if m.address?
|
8
|
+
@registry.each { |mask,channels|
|
9
|
+
if(Irc.netmaskmatch(mask, m.source) &&
|
10
|
+
(channels.empty? || channels.include?(m.channel)))
|
11
|
+
@bot.mode(m.channel, "+o", m.sourcenick)
|
12
|
+
return
|
31
13
|
end
|
14
|
+
}
|
32
15
|
end
|
33
16
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
if(ma[1] && channels)
|
38
|
-
@registry[ma[1]] = channels.split(/,\s*/).collect { |x|
|
39
|
-
x.strip
|
40
|
-
}
|
41
|
-
m.okay
|
42
|
-
else
|
43
|
-
m.reply @bot.lang.get('dunno')
|
44
|
-
end
|
17
|
+
def add(m, params)
|
18
|
+
@registry[params[:mask]] = params[:channels].dup
|
19
|
+
m.okay
|
45
20
|
end
|
46
21
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
22
|
+
def rm(m, params)
|
23
|
+
unless @registry.has_key?(params[:mask])
|
24
|
+
m.reply @bot.lang.get('dunno')
|
25
|
+
return
|
26
|
+
end
|
27
|
+
if (!params[:channels].empty? && @registry[params[:mask]] != nil)
|
28
|
+
params[:channels].each do |c|
|
29
|
+
@registry[params[:mask]] = @registry[params[:mask]].reject {|ele| ele =~ /^#{c}$/i}
|
30
|
+
end
|
31
|
+
if @registry[params[:mask]].empty?
|
32
|
+
@registry.delete(params[:mask])
|
33
|
+
end
|
34
|
+
else
|
35
|
+
@registry.delete(params[:mask])
|
36
|
+
end
|
37
|
+
m.okay
|
53
38
|
end
|
54
39
|
|
55
|
-
def
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
40
|
+
def list(m, params)
|
41
|
+
debug @registry.length
|
42
|
+
if(@registry.length > 0)
|
43
|
+
@registry.each { |mask,channels|
|
44
|
+
m.reply "#{mask} in #{channels.empty? ? 'all channels' : channels.join(', ')}"
|
45
|
+
}
|
46
|
+
else
|
47
|
+
m.reply "No entries"
|
48
|
+
end
|
63
49
|
end
|
64
50
|
end
|
65
51
|
|
66
52
|
plugin = AutoOP.new
|
67
|
-
|
53
|
+
|
54
|
+
plugin.map 'autoop list', :action => 'list'
|
55
|
+
plugin.map 'autoop add :mask *channels', :action => 'add'
|
56
|
+
plugin.map 'autoop add :mask', :action => 'add'
|
57
|
+
plugin.map 'autoop rm :mask *channels', :action => 'rm'
|
58
|
+
plugin.map 'autoop rm :mask', :action => 'rm'
|
68
59
|
|
@@ -0,0 +1,205 @@
|
|
1
|
+
# Plugin for the Ruby IRC bot (http://linuxbrit.co.uk/rbot/)
|
2
|
+
#
|
3
|
+
# Managing kick and bans, automatically removing bans after timeouts, quiet bans, and kickban/quietban based on regexp
|
4
|
+
#
|
5
|
+
# Commands are little Ruby programs that run in the context of the command plugin. You
|
6
|
+
# can create them directly in an IRC channel, and invoke them just like normal rbot plugins.
|
7
|
+
#
|
8
|
+
# (c) 2006 Marco Gulino <marco@kmobiletools.org>
|
9
|
+
# Licensed under GPL V2.
|
10
|
+
|
11
|
+
|
12
|
+
class BansPlugin < Plugin
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
if @registry.has_key?(:bans)
|
16
|
+
@bansregexps = @registry[:bans]
|
17
|
+
else
|
18
|
+
@bansregexps = Hash.new
|
19
|
+
end
|
20
|
+
|
21
|
+
if @registry.has_key?(:bansmasks)
|
22
|
+
@whitelist = @registry[:bansmasks]
|
23
|
+
else
|
24
|
+
@whitelist = Hash.new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def save
|
30
|
+
@registry[:bans] = @bansregexps
|
31
|
+
@registry[:bansmasks] = @whitelist
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
def help(plugin, topic="")
|
38
|
+
case topic
|
39
|
+
when "kickbans"
|
40
|
+
return "bans ban|quietban nick [channel] [timer]: bans|quietbans a nick from the channel for a specified time. bans kick nick [channel] [message]: kicks <nick> from <channel> with kick <message>. bans kickban nick [channel] [timer] [message]: kick+ban, same parameters as before. timer is always specified as <number><unit>, like 3m, 10s, 1h."
|
41
|
+
when "whitelist"
|
42
|
+
return "bans addwhitelist <mask>: adds <mask> to whitelist (NEVER regexp ban this). bans whitelist: shows current whitelist. bans delwhitelist <key>: delete whitelist entry <key>."
|
43
|
+
when "regexpbans"
|
44
|
+
return "bans addregexp type [timer] regexp: listens for <regexp>, then do actions depending on <type> (\"quietban\" or \"kickban\", currently). If timer if specified, it removes the ban after timer expires. timer is always specified as <number><unit>, like 3m, 10s, 1h. bans delregexp <key>: remove watching for regexp <key>. bans listregexps: show current regexp watching list."
|
45
|
+
else
|
46
|
+
return "Topics: \"kickbans\", \"whitelist\", \"regexpbans\""
|
47
|
+
end
|
48
|
+
# return "Channel administration plugin. bans ban nick [channel] [timer]: bans a nick from the channel for a specified time; bans unban nick [channel]: removes the ban on <nick>; bans quiet nick [channel] [timer] and bans unquiet nick [channel]: same as ban and unban, but uses quiet ban instead. Timer is specified as 6s, 10m, 2h. If channel is not specified will use current channel.\nbans listregexps|addregexp type timeout regexp|delregexp: regexp banning management. Type can be quietban or kickban"
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def cmd_setmode(m, nick, channel, smode, time, umode )
|
53
|
+
channel=channel != '####currentchannel' ? channel : m.target
|
54
|
+
timercnt=/^(\d+)([smh])$/.match(time)[1]
|
55
|
+
timeru=/^(\d+)([smh])$/.match(time)[2]
|
56
|
+
timer = timercnt.to_i if timeru == "s"
|
57
|
+
timer = timercnt.to_i*60 if timeru == "m"
|
58
|
+
timer = timercnt.to_i*3600 if timeru == "h"
|
59
|
+
if timer > 0 then @bot.timer.add_once(timer, m ) {|m|
|
60
|
+
@bot.sendq("MODE #{channel} #{umode} #{nick}")
|
61
|
+
# m.reply("Undo mode")
|
62
|
+
} end
|
63
|
+
|
64
|
+
@bot.sendq("MODE #{channel} #{smode} #{nick}")
|
65
|
+
# m.reply "ban cmd nick=#{nick} channel=#{channel} timer=#{timercnt} #{timeru} #{timer}"
|
66
|
+
end
|
67
|
+
def cmd_dokick(m, nick, channel, message)
|
68
|
+
channel=channel != '####currentchannel' ? channel : m.target
|
69
|
+
@bot.sendq("KICK #{channel} #{nick} :#{message}")
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def cmd_kick(m,params)
|
74
|
+
cmd_dokick(m,params[:nick], params[:channel], params[:message])
|
75
|
+
end
|
76
|
+
def cmd_ban(m, params)
|
77
|
+
cmd_setmode(m, params[:nick], params[:channel], "+b", params[:timer], "-b")
|
78
|
+
end
|
79
|
+
def cmd_kickban(m,params)
|
80
|
+
cmd_setmode(m, params[:nick], params[:channel], "+b", params[:timer], "-b")
|
81
|
+
cmd_dokick(m,params[:nick], params[:channel], params[:message])
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def cmd_quietban(m, params)
|
86
|
+
cmd_setmode(m, params[:nick], params[:channel], "+q", params[:timer], "-q")
|
87
|
+
end
|
88
|
+
def cmd_unban(m, params)
|
89
|
+
cmd_setmode(m, params[:nick], params[:channel], "-b", "0s", "")
|
90
|
+
end
|
91
|
+
def cmd_unquiet(m, params)
|
92
|
+
cmd_setmode(m, params[:nick], params[:channel], "-q", "0s", "")
|
93
|
+
end
|
94
|
+
|
95
|
+
def listen(m)
|
96
|
+
if @bansregexps.length <= 0 then return end
|
97
|
+
@whitelist.each_key do |key|
|
98
|
+
if Irc.netmaskmatch(@whitelist[key], m.source) then
|
99
|
+
return
|
100
|
+
end
|
101
|
+
next
|
102
|
+
end
|
103
|
+
|
104
|
+
@bansregexps.each_key do |key|
|
105
|
+
match=@bansregexps[key][2]
|
106
|
+
if m.message =~ /^.*#{match}.*$/i then
|
107
|
+
case @bansregexps[key][0]
|
108
|
+
when "quietban"
|
109
|
+
cmd_setmode(m, m.sourcenick, m.channel, "+q", @bansregexps[key][1], "-q")
|
110
|
+
return
|
111
|
+
when "kickban"
|
112
|
+
cmd_setmode(m, m.sourcenick, m.channel, "+b", @bansregexps[key][1], "-b")
|
113
|
+
cmd_dokick(m, m.sourcenick, m.channel, "Autokick")
|
114
|
+
return
|
115
|
+
end
|
116
|
+
end
|
117
|
+
next
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def cmd_addregexp(m, params)
|
122
|
+
toadd=Array[ params[:type], params[:timeout], "#{params[:regexp]}" ]
|
123
|
+
regsize=@bansregexps.length+1
|
124
|
+
# m.reply("Current registry size: #{regsize}")
|
125
|
+
|
126
|
+
@bansregexps[regsize]=toadd
|
127
|
+
|
128
|
+
# @bansregexps.store(toadd)
|
129
|
+
regsize=@bansregexps.length
|
130
|
+
# m.reply("New registry size: #{regsize}")
|
131
|
+
m.reply("Done.")
|
132
|
+
end
|
133
|
+
def cmd_listregexp(m, params)
|
134
|
+
if @bansregexps.length == 0
|
135
|
+
m.reply("No regexps stored."); return
|
136
|
+
end
|
137
|
+
@bansregexps.each_key do |key|
|
138
|
+
m.reply("Key: #{key}, type: #{@bansregexps[key][0]}, timeout: #{@bansregexps[key][1]}, pattern: #{@bansregexps[key][2]}")
|
139
|
+
sleep 1
|
140
|
+
next
|
141
|
+
end
|
142
|
+
end
|
143
|
+
def cmd_delregexp(m, params)
|
144
|
+
index=params[:index]
|
145
|
+
@bansregexps.each_key do |key|
|
146
|
+
if ( "#{key}" == "#{index}" ) then
|
147
|
+
@bansregexps.delete(key)
|
148
|
+
m.reply("Done.")
|
149
|
+
return
|
150
|
+
end
|
151
|
+
next
|
152
|
+
end
|
153
|
+
m.reply("Key #{index} not found.")
|
154
|
+
end
|
155
|
+
def cmd_whitelistadd(m, params)
|
156
|
+
regsize=@whitelist.length+1
|
157
|
+
@whitelist[regsize]=params[:netmask]
|
158
|
+
m.reply("Done.")
|
159
|
+
end
|
160
|
+
def cmd_whitelist(m, params)
|
161
|
+
if @whitelist.length == 0
|
162
|
+
m.reply("Whitelist is empty."); return
|
163
|
+
end
|
164
|
+
@whitelist.each_key do |key|
|
165
|
+
m.reply("Key: #{key}, netmask: #{@whitelist[key]}")
|
166
|
+
sleep 1
|
167
|
+
next
|
168
|
+
end
|
169
|
+
end
|
170
|
+
def cmd_whitelistdel(m, params)
|
171
|
+
index=params[:index]
|
172
|
+
@whitelist.each_key do |key|
|
173
|
+
if ( "#{key}" == "#{index}" ) then
|
174
|
+
@whitelist.delete(key)
|
175
|
+
m.reply("Done.")
|
176
|
+
return
|
177
|
+
end
|
178
|
+
next
|
179
|
+
end
|
180
|
+
m.reply("Key #{index} not found.")
|
181
|
+
end
|
182
|
+
end
|
183
|
+
plugin = BansPlugin.new
|
184
|
+
plugin.register("bans")
|
185
|
+
|
186
|
+
plugin.map 'bans whitelist', :action => 'cmd_whitelist', :auth => 'bans'
|
187
|
+
plugin.map 'bans delwhitelist :index', :action => 'cmd_whitelistdel', :auth => 'bans', :requirements => { :index => /^\d+$/ }
|
188
|
+
plugin.map 'bans addwhitelist :netmask', :action => 'cmd_whitelistadd', :auth => 'bans'
|
189
|
+
plugin.map 'bans delregexp :index', :action => 'cmd_delregexp', :auth => 'bans', :requirements => { :index => /^\d+$/ }
|
190
|
+
plugin.map 'bans addregexp :type :timeout *regexp', :action => 'cmd_addregexp', :auth => 'bans', :requirements => {:timeout => /^\d+[smh]$/, :type => /(quietban)|(kickban)/ }, :defaults => { :timeout => "0s" }
|
191
|
+
plugin.map 'bans listregexps', :action => 'cmd_listregexp', :auth => 'bans'
|
192
|
+
plugin.map 'bans ban :nick :channel :timer', :action => 'cmd_ban', :auth => 'bans', :requirements => {:timer => /^\d+[smh]$/, :channel => /^#+[^\s]+$/}, :defaults => {:channel => '####currentchannel', :timer => '0s'}
|
193
|
+
plugin.map 'bans quiet :nick :channel :timer', :action => 'cmd_quietban', :auth => 'bans', :requirements => {:timer => /^\d+[smh]$/, :channel => /^#+[^\s]+$/}, :defaults => {:channel => '####currentchannel', :timer => '0s'}
|
194
|
+
|
195
|
+
plugin.map 'bans kick :nick :channel *message', :action => 'cmd_kick', :auth => 'bans', :requirements => {:channel => /^#+[^\s]+$/}, :defaults => {:channel => '####currentchannel', :message => 'Au revoir.'}
|
196
|
+
plugin.map 'bans kickban :nick :channel :timer *message', :action => 'cmd_kickban', :auth => 'bans', :requirements => {:channel => /^#+[^\s]+$/, :timer => /^\d+[smh]$/ }, :defaults => {:channel => '####currentchannel', :message => 'Au revoir.', :timer => '0s'}
|
197
|
+
|
198
|
+
|
199
|
+
plugin.map 'bans unban :nick :channel', :action => 'cmd_unban', :auth => 'bans', :requirements => { :channel => /^#+[^\s]+$/}, :defaults => {:channel => '####currentchannel'}
|
200
|
+
plugin.map 'bans unquiet :nick :channel', :action => 'cmd_unquiet', :auth => 'bans', :requirements => { :channel => /^#+[^\s]+$/}, :defaults => {:channel => '####currentchannel'}
|
201
|
+
|
202
|
+
#plugin.map 'admin kick :nick :channel *message', :action => 'cmd_kick', :auth => 'admin'
|
203
|
+
#plugin.map 'admin kickban :nick :channel *message', :action => 'cmd_kickban' :auth => 'admin'
|
204
|
+
#plugin.register("quietban")
|
205
|
+
#plugin.register("kickban")
|