Last active
September 4, 2015 06:25
-
-
Save Voker57/278107 to your computer and use it in GitHub Desktop.
"dick" plugin for rbot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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