RMX-OS Chat Filter
Authors: Nathmatt
Version: 2.2
Type: Message Filter
Key Term: RMX-OS Plugin
Introductionfilters game messages
Features
- Easy to add words to filter
- Easy to add word to filter it with
- Now removes any indication of the word
Screenshotsnot really needed
Demono demo
Script#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# RMX-OS Chat Filter by Nathmatt
# Version: 2.2
# Type: Message filter
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This work is protected by the following license:
# #----------------------------------------------------------------------------
# #
# # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #
# # You are free:
# #
# # to Share - to copy, distribute and transmit the work
# # to Remix - to adapt the work
# #
# # Under the following conditions:
# #
# # Attribution. You must attribute the work in the manner specified by the
# # author or licensor (but not in any way that suggests that they endorse you
# # or your use of the work).
# #
# # Noncommercial. You may not use this work for commercial purposes.
# #
# # Share alike. If you alter, transform, or build upon this work, you may
# # distribute the resulting work only under the same or similar license to
# # this one.
# #
# # - For any reuse or distribution, you must make clear to others the license
# # terms of this work. The best way to do this is with a link to this web
# # page.
# #
# # - Any of the above conditions can be waived if you get permission from the
# # copyright holder.
# #
# # - Nothing in this license impairs or restricts the author's moral rights.
# #
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
module Chat_Filter
Flitered_Words = ['crap']
Non_Filtered = ['scrap']
Replace_With ='***'
end
class RMXOS::Network
alias filter_add_message add_message
def add_message(id, message, color, action = false)
if @players[id] != nil
message = filter_messages(message)
end
filter_add_message(id, message, color, action = false)
end
def filter_messages(text)
message = text.dup
text.each(' '){|word|
w = word.downcase
if !Chat_Filter::Non_Filtered.include?(w)
Chat_Filter::Flitered_Words.each{|filter|
if w.gsub!("#{filter}") {''} != nil
message.gsub!("#{word}") {Chat_Filter::Replace_With+' '}
end}
end}
return message
end
end
Instructionsjust place this below RMX-OS and above main
Compatibilityno issues known
Credits and Thanks
Author's Notesif a word includes the filtered word the entire word is replaced unless it is included in the Non_Filtered array
post any bugs or suggestions here
Thanks very much for making this:)! I'll be sure to try it out and tell you about any problems I find.
Ok, just a few problems and suggestions for improvement: first of all, if you say the word within another then it isn't filtered (doesn't really matter, and I didn't specify it, just pointint it out). Also, now whenever the player talks a small non-game info box comes up telling them each word they say. This causes great inconvenience during gameplay, because it goes one word at a time. This is especially inconvenient when the player types /cmd, because it tells them all the commands one word at a time, and in the actual chatbox they are all jumbled together into one unreadable streak of gray text. As for the text in the chatbox, it is all squeezed into one line now, whereas beforehand it was split into different lines so it was readable. Also, when the server gives the player a message, such as "Bob has join the party," there are no spaces, so it looks like "Bobhasjoinedtheparty."
The reason the things pop up is because nathmatt left debug stuff in. Just delete the lines that only say
. The other problems I don't know. Oh, and one bug I found is that if you put an exclamation point after a word it gets through.
Edit: I'm not getting the no space error so I'm not sure why you are.... Did you do anything weird to the script....
update 1.5 it now removes any indication of the word in that capitalization i hope to figure out a way to fix that
Just have all the bad words you define be in all lower case.
You could also include a few regular expessions to not have it replace words that are with in other words.
ex. "ass" is a bad word.
the word "assisstance" would look like this: "***isstance"
EDIT: Nevermind the capitilization. I see you said you fixed that. oops.
i thought of using.downcase but then nothing you typed would every be capitalized
Don't use downcase!, use downcase.
If you scripted it right it would not modify the original string, but only scan it for bad words in all lower case. It won't actually change it unless you are doing something like this.
old_string = 'HEY THIS IS CAPS'
new_string = old_string.downcase.gsub('caps') { '***' }
This returns: "hey this is ***"
If you simply do this, the capitilization remains the same:
old_string = 'HEY THIS IS CAPS'
old_string.downcase.gsub!('caps') { '***' }
This returns: "HEY THIS IS ***"
update 2.0 fixed it the entire word gets replaced unless it is included in the Non_Filtered array
Hey, awesome script!
I found an issue though. If the string is multiple words, and the first word is filtered, it crashes on line 61 with 'ArgumentError Occurred'.
text.each(' '){|word|Chat_Filter::Flitered_Words.each{|filter|
update 2.1 fixed above error had to do with editing the string i was going trough so i just duplicated it using .dup
Thanks, everything seems to work now!
Hey I've got a minor issue with this, nothing horrible, but i was wondering if it's fixable. When a user types /cmd to see the commands, certain ones are blotted out if "ass" is a bad word. For instance, /newpass. Even if I make it a non-filtered word, it's still blotted out in /cmd. Any ideas?
update 2.2 fixed above bug