summaryrefslogtreecommitdiff
path: root/data/rbot/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r--data/rbot/plugins/lart.rb101
-rw-r--r--data/rbot/plugins/lart/larts-english98
-rw-r--r--data/rbot/plugins/lart/larts-italian25
-rw-r--r--data/rbot/plugins/lart/larts-japanese10
-rw-r--r--data/rbot/plugins/lart/praises-english5
-rw-r--r--data/rbot/plugins/lart/praises-italian4
-rw-r--r--data/rbot/plugins/lart/praises-japanese3
7 files changed, 197 insertions, 49 deletions
diff --git a/data/rbot/plugins/lart.rb b/data/rbot/plugins/lart.rb
index aeaad733..cb8e57b7 100644
--- a/data/rbot/plugins/lart.rb
+++ b/data/rbot/plugins/lart.rb
@@ -28,58 +28,61 @@
class LartPlugin < Plugin
def initialize
- @larts = Array.new
- @praises = Array.new
- @lartfile = ""
- @praisefile = ""
- @changed = false
+ @larts = nil
+ @praises = nil
+
super
+ # after intialization #set_language is called with the language set in the bot configuration
+ # this loads the larts/praises from the registry
+ end
+
+ def load_static_files(path, suffix)
+ entries = {}
+ Dir.glob("#{path}/#{suffix}-*").each { |filename|
+ language = filename[filename.rindex('-')+1..-1]
+ entries[language] = File.readlines(filename).map(&:chomp)
+ }
+ entries
end
def set_language(lang)
save
- # We may be on an old installation, so on the first run read non-language-specific larts
- unless defined?(@oldlart)
- @oldlart = datafile 'larts'
- @oldpraise = datafile 'praise'
- end
+ @lang = lang
+ @larts = @registry[:larts]
+ @praises = @registry[:praises]
+
+ # for migrations try to read lart from bot data first (this is usually in ~/.rbot/lart:
+ if not @larts or not @praises
+ log "migrate existing larts or praises from #{datafile}"
- @lartfile.replace(datafile("larts-#{lang}"))
- @praisefile.replace(datafile("praises-#{lang}"))
- @larts.clear
- @praises.clear
- if File.exists? @lartfile
- IO.foreach(@lartfile) { |line|
- @larts << line.chomp
- }
- elsif File.exists? @oldlart
- IO.foreach(@oldlart) { |line|
- @larts << line.chomp
- }
+ @larts = load_static_files(datafile, 'larts')
+ @praises = load_static_files(datafile, 'praises')
end
- if File.exists? @praisefile
- IO.foreach(@praisefile) { |line|
- @praises << line.chomp
- }
- elsif File.exists? @oldpraise
- IO.foreach(@oldpraise) { |line|
- @praises << line.chomp
- }
+
+ # without migrations, the initial data files we load from is located in the plugin directory
+ # that is the directory in which the plugin file itself is located (.../data/rbot/plugins/ usually)
+ if not @larts or not @praises
+ log "load initial larts and praises from #{plugin_path}"
+
+ initial_path = File.join(plugin_path, 'lart')
+ @larts = load_static_files(initial_path, 'larts')
+ @praises = load_static_files(initial_path, 'praises')
end
- @changed = false
+ end
+
+ def larts
+ @larts[@lang]
+ end
+
+ def praises
+ @praises[@lang]
end
def save
- return unless @changed
- Dir.mkdir(datafile) unless FileTest.directory? datafile
- Utils.safe_save(@lartfile) { |file|
- file.puts @larts
- }
- Utils.safe_save(@praisefile) { |file|
- file.puts @praises
- }
- @changed = false
+ @registry[:larts] = @larts
+ @registry[:praises] = @praises
+ @registry.flush
end
def help(plugin, topic="")
@@ -87,7 +90,7 @@ class LartPlugin < Plugin
end
def handle_lart(m, params)
- lart = @larts[get_msg_idx(@larts.length)]
+ lart = larts[get_msg_idx(larts.length)]
if not lart
m.reply "I dunno any larts"
return
@@ -108,7 +111,7 @@ class LartPlugin < Plugin
end
def handle_praise(m, params)
- praise = @praises[get_msg_idx(@praises.length)]
+ praise = praises[get_msg_idx(praises.length)]
if not praise
m.reply "I dunno any praises"
return
@@ -128,20 +131,20 @@ class LartPlugin < Plugin
end
def handle_addlart(m, params)
- @larts << params[:lart].to_s
+ @larts[@lang] << params[:lart].to_s
@changed = true
m.okay
end
def handle_rmlart(m, params)
- @larts.delete params[:lart].to_s
+ @larts[@lang].delete params[:lart].to_s
@changed = true
m.okay
end
def handle_listlart(m, params)
rx = Regexp.new(params[:lart].to_s, true)
- list = @larts.grep(rx)
+ list = larts.grep(rx)
unless list.empty?
m.reply list.join(" | "), :split_at => /\s+\|\s+/
else
@@ -150,20 +153,20 @@ class LartPlugin < Plugin
end
def handle_addpraise(m, params)
- @praises << params[:praise].to_s
+ @praises[@lang] << params[:praise].to_s
@changed = true
m.okay
end
def handle_rmpraise(m, params)
- @praises.delete params[:praise].to_s
+ @praises[@lang].delete params[:praise].to_s
@changed = true
m.okay
end
def handle_listpraise(m, params)
rx = Regexp.new(params[:praise].to_s, true)
- list = @praises.grep(rx)
+ list = praises.grep(rx)
unless list.empty?
m.reply list.join(" | "), :split_at => /\s+\|\s+/
else
@@ -177,7 +180,7 @@ class LartPlugin < Plugin
end
def get_msg_idx(max)
- idx = rand(max)
+ rand(max)
end
end
diff --git a/data/rbot/plugins/lart/larts-english b/data/rbot/plugins/lart/larts-english
new file mode 100644
index 00000000..c3a25880
--- /dev/null
+++ b/data/rbot/plugins/lart/larts-english
@@ -0,0 +1,98 @@
+swaps <who>'s shampoo with nair
+installs windows on <who>'s machine
+forces <who> to use perl for 3 weeks
+registers <who>'s name with 50 known spammers
+resizes <who>'s terminal to 40x24
+takes <who>'s tea
+dispenses <who>'s email address to a few hundred 'bulk mailing services'
+pokes <who> in the eye
+beats <who> senseless with a 50lb Unix manual
+cats /dev/urandom into <who>'s ear
+signs <who> up for AOL
+enrolls <who> in Visual Basic 101
+sporks <who>
+drops a truckload of VAXen on <who>
+judo chops <who>
+resizes <who>'s terminal to 40x24
+formats <who>'s harddrive to fat12
+rm -rf's <who>
+stabs <who>
+steals <who>'s mojo
+strangles <who> with a doohicky mouse cord
+whacks <who> with the cluebat
+sells <who> on E-Bay
+uses <who> as a biological warfare study
+uses the "Customer Appreciation Bat" on <who>
+reads <who> some vogon poetry
+puts <who> in the Total Perspective Vortex
+casts <who> into the fires of Mt. Doom
+gives <who> a melvin
+turns over <who> to Agent Smith to be "bugged"
+takes away <who>'s internet connection
+pushes <who> past the Shoe Event Horizon
+counts "1, 2, 5... er... 3!" and hurls the Holy Handgrenade Of Antioch at <who>
+puts <who> in a nest of camel spiders
+makes <who> read slashdot at -1
+puts "alias vim=emacs" in <who>'s /etc/profile
+uninstalls ld from <who>'s system
+locks <who> in the Chateau d'If
+signs <who> up for getting hit on the head lessons
+makes <who> try to set up a Lexmark printer
+fills <who>'s Visene eyedrop bottle with lime juice
+casts <who> into the fires of Mt. Doom.
+gives <who> a Chicago Steamer
+rips off <who>'s arm, and uses it to beat them to death
+pierces <who>'s nose with a rusty paper hole puncher
+pokes <who> with a rusty nail
+puts sugar between <who>'s bedsheets
+pours sand into <who>'s oatmeal
+mixes epoxy into <who>'s toothpaste
+puts Icy-Hot in <who>'s lip balm
+straps <who> to a chair, and plays a endless low bitrate MP3 loop of "the world's most annoying sound" from "Dumb and Dumber"
+tells Dr. Dre that <who> was talking smack
+forces <who> to use a Commodore 64 for all their word processing
+smacks <who> in the face with a burlap sack full of broken glass
+puts <who> in a room with several heavily armed manic depressives
+makes <who> watch reruns of "Blue's Clues"
+puts lye in <who>'s coffee
+tattoos the Windows symbol on <who>'s ass
+lets Borg have his way with <who>
+signs <who> up for line dancing classes at the local senior center
+wakes <who> out of a sound sleep with some brand new nipple piercings
+gives <who> a 2 guage Prince Albert
+forces <who> to eat all their veggies
+covers <who>'s toilet paper with lemon-pepper
+fills <who>'s ketchup bottle with Dave's Insanity sauce
+forces <who> to stare at an incredibly frustrating and seemingly neverending IRC political debate
+knocks two of <who>'s teeth out with a 2x4
+removes debian from <who>'s system
+uses <who>'s debian cds for skeet shooting practice
+gives <who>'s phone number to Borg
+posts <who>'s IP and root password on alt.2600
+forces <who> to use words like "irregardless" and "administrate" (thereby sounding like a real dumbass)"
+tickles <who> until they wet their pants and pass out
+replaces <who>'s KY with elmer's clear wood glue
+replaces <who>'s TUMS with alka-seltzer tablets
+squeezes habanero pepper juice into <who>'s tub of vaseline for <who>
+submits <who>'s photo to the people at SA for photoshopping
+Forces <who> to learn the Win32 API
+gives <who> an atomic wedgie
+ties <who> to a chair and forces them to listen to 'N Sync at full blast
+forces <who> to use emacs for text editing
+frowns at <who> really really hard
+jabs a hot car lighter into <who>'s eye sockets
+forces <who> to browse the web with IE
+takes <who> out at the knees with a broken pool cue
+forces <who> to listen to only emo music
+signs <who> up for the Iowa State Ferret Legging Championship
+attempts to hotswap <who>'s RAM
+donkey punches <who>
+puts track spikes into <who>'s side
+replaces <who>'s Astroglide with JB Weld
+replaces <who>'s hypertension pills with rat poison pellets
+replaces <who>s jock itch cream with Nair
+does the Australian Death Grip on <who>
+dances upon the grave of <who>'s ancestors.
+farts in <who>'s general direction
+flogs <who> with stinging neddle
+hands <who> a poison ivy joint
diff --git a/data/rbot/plugins/lart/larts-italian b/data/rbot/plugins/lart/larts-italian
new file mode 100644
index 00000000..bc4b4e05
--- /dev/null
+++ b/data/rbot/plugins/lart/larts-italian
@@ -0,0 +1,25 @@
+scambia lo shampoo di <who> con crema depilatoria
+installa Windows 3.1 sul computer di <who>
+costringe <who> a programmare in Perl per 3 settimane
+manda l'indirizzo email di <who> a 50 noti spammer
+restringe il terminale di <who> a 40x24
+ruba il the di <who>
+picchia <who> a sangue sulle gengive con una mazza ferrata arrugginita
+vende <who> su eBay
+ficca un peperoncino su per il culo di <who>
+fa <who> a fettine
+punzecchia la bambola voodoo di <who>
+riformatta il disco fisso di <who>
+brucia la collezione di fumetti di <who>
+brucia la biblioteca di <who>
+brucia la macchina di <who>
+mette zucchero nel serbatoio della moto di <who>
+legge a <who> un po' di poesia Vogon
+svuota il frigorifero di <who>
+picchia <who> in faccia con la 'Ricerca' di Proust
+usa <who> come cavia in esperimenti di guerra batteriologica
+pubblica su internet la foto di <who> sedut@ al cesso
+scrive il numero di telefono di <who> su tutti i cessi pubblici
+scollega la connessione ad internet di <who>
+strappa le braccia di <who> e le usa per picchiarl@ a morte
+nasconde un nido di vipere nel cuscino di <who>
diff --git a/data/rbot/plugins/lart/larts-japanese b/data/rbot/plugins/lart/larts-japanese
new file mode 100644
index 00000000..27982595
--- /dev/null
+++ b/data/rbot/plugins/lart/larts-japanese
@@ -0,0 +1,10 @@
+<who>のパソコンにWindowsをインスタールする
+<who>に3週間Perlを使わせる
+<who>を叩き付ける
+<who>の手を剥して、その手で<who>に打つ
+Ebayで<who>を売る
+<who>のコーヒーに灰汁を入れる
+<who>をはらきりさせる
+<who>を刺身に作る
+<who>に心臓麻痺させる
+<who>の名前をデスノートに書く
diff --git a/data/rbot/plugins/lart/praises-english b/data/rbot/plugins/lart/praises-english
new file mode 100644
index 00000000..3d89df74
--- /dev/null
+++ b/data/rbot/plugins/lart/praises-english
@@ -0,0 +1,5 @@
+hugs <who>
+gives <who> some love
+gives <who> a cookie
+slaps <who> heartily on the back
+tickles <who>
diff --git a/data/rbot/plugins/lart/praises-italian b/data/rbot/plugins/lart/praises-italian
new file mode 100644
index 00000000..9467cf95
--- /dev/null
+++ b/data/rbot/plugins/lart/praises-italian
@@ -0,0 +1,4 @@
+abbraccia <who>
+adora <who>
+invita <who> ad una cena luculliana
+da' un'amichevole pacca sulle spalle a <who>
diff --git a/data/rbot/plugins/lart/praises-japanese b/data/rbot/plugins/lart/praises-japanese
new file mode 100644
index 00000000..12c0abc3
--- /dev/null
+++ b/data/rbot/plugins/lart/praises-japanese
@@ -0,0 +1,3 @@
+<who>とチュウする
+<who>にクキーあげる
+<who>ダイスキ!