Skip to content

Instantly share code, notes, and snippets.

@Voker57
Last active September 4, 2015 06:25
Show Gist options
  • Save Voker57/278107 to your computer and use it in GitHub Desktop.
Save Voker57/278107 to your computer and use it in GitHub Desktop.
"dick" plugin for rbot
class DickPlugin < Plugin
def name
"dick"
end
def help(plugin, topic="")
"Adds a bit of huymor to russian words"
end
def hui(m, params)
subj = m.params.to_s
the_map = {
"у" => "ю",
"а" => "я",
"э" => "е",
"ы" => "и",
"о" => "ё"
}
vowels = the_map.to_a.flatten
subja = subj.split(/\s+/)
rstr = subja.map do |subj|
subj.gsub!(/^[^#{vowels}]+/u, "")
subj.gsub!(/^[#{vowels}]/u) do |v|
if the_map.has_key? v
the_map[v]
else
v
end
end
"ху" + (subj.empty? ? "й" : subj)
end.join(" ")
m.reply(rstr)
end
def unhui(m, params)
unmap = {
"ю" => "у",
"я" => "а",
"е" => "э",
"и" => "ы",
"ё" => "о"
}
m.reply(m.params.map do |w|
w.gsub(/ху(.)/u) do |a|
warning a.inspect
unmap[$1] || $1
end
end.join(" "))
end
end
plugin = DickPlugin.new
plugin.register "хуй"
plugin.map 'хуй', :action => "hui"
plugin.map 'нехуй', :action => "unhui"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment