split quote/fun modules
parent
79e6dbd495
commit
09591b03d1
|
@ -1,12 +1,7 @@
|
|||
require 'open-uri'
|
||||
require 'json'
|
||||
|
||||
class Mod_Fun < Vrobot4::Module::Module
|
||||
def self.type() "Fun" end
|
||||
Vrobot4::Module.add_module_type self
|
||||
|
||||
QDB = "http://greyserv.net/qdb"
|
||||
|
||||
def initialize info
|
||||
super
|
||||
register :c_carmack, "carmack", "mmmmmmmmmm"
|
||||
|
@ -16,7 +11,6 @@ class Mod_Fun < Vrobot4::Module::Module
|
|||
register :c_box, "box", "S H I T P O S T I N G"
|
||||
register :c_zdoom, "zdoom", "ZDoom™"
|
||||
register :c_marble, "marble", "mararuaruaruaruarb"
|
||||
register :c_quote, "quote", "Queries the Doominati Quote Database."
|
||||
register :c_what, "what", "What the fuck did you just fucking say about"
|
||||
end
|
||||
|
||||
|
@ -40,7 +34,7 @@ class Mod_Fun < Vrobot4::Module::Module
|
|||
end
|
||||
|
||||
def c_marble m, argv
|
||||
check_args argv, "", "N"
|
||||
check_args argv, "N"
|
||||
|
||||
if argv.empty? then n = 20
|
||||
else n = argv.to_i end
|
||||
|
@ -57,29 +51,6 @@ class Mod_Fun < Vrobot4::Module::Module
|
|||
m.reply text
|
||||
end
|
||||
|
||||
def c_quote m, argv
|
||||
if argv.empty?
|
||||
q, num = nil, nil
|
||||
max = JSON.parse(open(QDB + "/interface.cgi").read)["numQuotes"]
|
||||
loop do
|
||||
num = rand(max) + 1
|
||||
q = open(QDB + "/q/" + num.to_s).read
|
||||
break unless m.serv.flags.include? "L" and
|
||||
(q.lines.count > 4 or q.length > 1000)
|
||||
end
|
||||
m.reply_b "Quote %i:\n" % [num] + q
|
||||
elsif Vrobot4.is_num? argv
|
||||
m.reply_b open(QDB + "/q/" + argv.to_i.to_s).read
|
||||
else
|
||||
raise ArgumentError, "Invalid query" if argv.include? ?&
|
||||
q = URI.escape argv
|
||||
info = JSON.parse(open(QDB + "/interface.cgi?query=" + q).read)
|
||||
raise ArgumentError, "No results" unless info["searchResults"].any?
|
||||
res = info["searchResults"].sample
|
||||
m.reply_b "Quote %i:\n" % [res] + open(QDB + "/q/" + res.to_s).read
|
||||
end
|
||||
end
|
||||
|
||||
def c_what m, argv
|
||||
if m.serv.flags.include? ?L
|
||||
m.reply "What the fuck did you just fucking say about me, you little bitch?"
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
require 'open-uri'
|
||||
require 'json'
|
||||
|
||||
class Mod_QDB < Vrobot4::Module::Module
|
||||
def self.type() "QDB" end
|
||||
Vrobot4::Module.add_module_type self
|
||||
|
||||
QDB = "http://greyserv.net/qdb"
|
||||
|
||||
def initialize info
|
||||
super
|
||||
register :c_quote, "quote", "Queries the Doominati Quote Database."
|
||||
end
|
||||
|
||||
def c_quote m, argv
|
||||
if argv.empty?
|
||||
q, num = nil, nil
|
||||
max = JSON.parse(open(QDB + "/interface.cgi").read)["numQuotes"]
|
||||
loop do
|
||||
num = rand(max) + 1
|
||||
q = open(QDB + "/q/" + num.to_s).read
|
||||
break unless m.serv.flags.include? "L" and
|
||||
(q.lines.count > 4 or q.length > 1000)
|
||||
end
|
||||
m.reply_b "Quote %i:\n" % [num] + q
|
||||
elsif Vrobot4.is_num? argv
|
||||
m.reply_b open(QDB + "/q/" + argv.to_i.to_s).read
|
||||
else
|
||||
raise ArgumentError, "Invalid query" if argv.include? ?&
|
||||
q = URI.escape argv
|
||||
info = JSON.parse(open(QDB + "/interface.cgi?query=" + q).read)
|
||||
raise ArgumentError, "No results" unless info["searchResults"].any?
|
||||
res = info["searchResults"].sample
|
||||
m.reply_b "Quote %i:\n" % [res] + open(QDB + "/q/" + res.to_s).read
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
## EOF
|
Loading…
Reference in New Issue