Pavitra
Joined: 14 Feb 2010
Posts: 157
Pavitra
Joined: 14 Feb 2010
Posts: 157
Pavitra
Joined: 14 Feb 2010
Posts: 157
Code:
5a6
> import md5
36c37
< rating = self.wordlist[string.lower(sentence[startidx:endidx])]
---
> rating = self.wordlist[md5.new(string.lower(sentence[startidx:endidx])).hexdigest()]
47c48
< rating = self.wordlist[string.lower(sentence[startidx:])]
---
> rating = self.wordlist[md5.new(string.lower(sentence[startidx:])).hexdigest()]
66c67
< rating = self.wordlist[string.lower(sentence[startidx:endidx])]
---
> rating = self.wordlist[md5.new(string.lower(sentence[startidx:endidx])).hexdigest()]
82c83
< rating = self.wordlist[string.lower(sentence[startidx:])]
---
> rating = self.wordlist[md5.new(string.lower(sentence[startidx:])).hexdigest()]Code:
14c14,15
< "anotherreallybadword" : Rating(xRatedR)\
---
> "anotherreallybadword" : Rating(xRatedR),\
> "41a41e087a065a83ef79950a2deb6c28" : Rating(xRatedR)\Code:
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path += ['./plasma']
>>> import xCensor
>>> xCensor.xCensor("this is a test xxxbadxxx reallybadword hashedbadword", 1)
'this is a test ***** reallybadword *****'
>>>
_________________
Have Ages, and link to them without bindings.
Last edited by Pavitra on Fri Apr 16, 2010 5:29 pm; edited 1 time in total
Pavitra
Joined: 14 Feb 2010
Posts: 157
Code:
#!/usr/bin/python
"""
This script converts a wordfilter file (xCensorFilters.py) from unhashed to
hashed format.
"""
import sys
import os
import string
import md5
num_args = len(sys.argv)
if num_args != 3:
print "Usage: ./xuHashifyWordfilter infile > outfile"
sys.exit(1)
if sys.argv[1] == sys.argv[2]:
print "Error: infile and outfile are the same. Aborting."
sys.exit(2)
if not os.path.isfile(sys.argv[1]):
print "Error:", sys.argv[1], "is not a file. Aborting."
sys.exit(3)
if os.path.exists(sys.argv[2]):
print "Error:", sys.argv[2], "exists. Aborting."
sys.exit(4)
with open(sys.argv[1], 'r') as f1:
text = f1.read()
intext = string.split(text, '\n')
outtext = ""
section_found = False
for line in intext:
if section_found:
if string.find(line, "\"") >= 0:
splitline = string.split(line, "\"", 2)
hashedline = splitline[0] + "\"" + md5.new(splitline[1]).hexdigest() + "\" " + string.lstrip(splitline[2], " ")
outtext += hashedline + "\n"
else:
outtext += line + "\n"
elif string.find(line, "ExactMatchListFilter") >= 0:
section_found = True
outtext += line + "\n"
else:
outtext += line + "\n"
with open(sys.argv[2], 'w') as f2:
f2.write(outtext)
Code:
"""
This module contains all the strings that need to localized for the Censor
This is not the real module... it is just here for compiling
"""
from ptWordFilter import *
xSentenceFilters = [\
REFilter( r'xxxbadxxx', Rating(xRatedX) ),\
ExactMatchListFilter(\
{
#reallybadword
"reallybadword" : Rating(xRatedR),\
#anotherreallybadword
"anotherreallybadword" : Rating(xRatedR),\
#hashedbadword
"hashedbadword" : Rating(xRatedR)\
# A 'real' badwords file wouldn't have these comments
# telling you what the hashes stand for.
}\
)\
]Code:
"""
This module contains all the strings that need to localized for the Censor
This is not the real module... it is just here for compiling
"""
from ptWordFilter import *
xSentenceFilters = [\
REFilter( r'xxxbadxxx', Rating(xRatedX) ),\
ExactMatchListFilter(\
{
#reallybadword
"618acd2e63b8c9ebe3e6bea721c6069f" : Rating(xRatedR),\
#anotherreallybadword
"2f8d6919273625e3e301d793b90f412e" : Rating(xRatedR),\
#hashedbadword
"41a41e087a065a83ef79950a2deb6c28" : Rating(xRatedR)\
# A 'real' badwords file wouldn't have these comments
# telling you what the hashes stand for.
}\
)\
]
_________________
Have Ages, and link to them without bindings.
Last edited by Pavitra on Fri Apr 16, 2010 5:29 pm; edited 1 time in total
Paradox
Joined: 09 May 2006
Posts: 1178
Location: British Columbia, Canada
Pavitra
Joined: 14 Feb 2010
Posts: 157
Paradox
Joined: 09 May 2006
Posts: 1178
Location: British Columbia, Canada
Pavitra
Joined: 14 Feb 2010
Posts: 157
DarK
Joined: 21 May 2006
Posts: 508
Pavitra
Joined: 14 Feb 2010
Posts: 157
AdamJohnso
Joined: 09 May 2006
Posts: 1252
Location: Milledgeville, GA
_________________
Pavitra
Joined: 14 Feb 2010
Posts: 157
Code:
diff --git a/python/xKI.py b/python/xKI.py
index 3a051ec..6c0b94d 100644
--- a/python/xKI.py
+++ b/python/xKI.py
@@ -292,0 +293 @@ gFeather = 0
+userdefined_CensorRating = xCensor.xRatedG
@@ -6662,0 +6664,43 @@ class xKI(ptModifier):
+
+
+
+ # New stuff starts here. ---------------------------------------------
+
+ # A quick rgrep didn't turn up the definition of PtGetLocalizedString,
+ # only a forward-declaration, so I won't be using it.
+ # Sorry, non-English-speakers. :(
+
+ if string.lower(chatmessage).startswith("/rating x"):
+ if AmICCR:
+ userdefined_CensorRating = xCensor.xRatedX
+ self.IAddRTChat(None, "Wordfilter rating set to X.", kChatSystemMessage)
+ else:
+ userdefined_CensorRating = xCensor.xRatedR
+ self.IAddRTChat(None, "Wordfilter rating set to R.", kChatSystemMessage)
+ return None
+ if string.lower(chatmessage).startswith("/rating r"):
+ userdefined_CensorRating = xCensor.xRatedR
+ self.IAddRTChat(None, "Wordfilter rating set to R.", kChatSystemMessage)
+ return None
+ if string.lower(chatmessage).startswith("/rating pg13") or string.lower(chatmessage).startswith("/rating pg-13"):
+ userdefined_CensorRating = xCensor.xRatedPG13
+ self.IAddRTChat(None, "Wordfilter rating set to PG-13.", kChatSystemMessage)
+ return None
+ if string.lower(chatmessage).startswith("/rating pg"):
+ userdefined_CensorRating = xCensor.xRatedPG
+ self.IAddRTChat(None, "Wordfilter rating set to PG.", kChatSystemMessage)
+ return None
+ if string.lower(chatmessage).startswith("/rating g"):
+ userdefined_CensorRating = xCensor.xRatedG
+ self.IAddRTChat(None, "Wordfilter rating set to G.", kChatSystemMessage)
+ return None
+ if string.lower(chatmessage).startswith("/rating"):
+ # Command recognized, but argument(s) missing or invalid.
+ self.IAddRTChat(None, "Usage: /rating <rating>\nValid ratings are G, PG, PG-13, R.", kChatSystemMessage)
+ return None
+
+
+ # New stuff ends here. ---------------------------------------------
+
+
+ Code:
diff --git a/python/xKI.py b/python/xKI.py
index 3a051ec..e79716e 100644
--- a/python/xKI.py
+++ b/python/xKI.py
@@ -6662,0 +6663,46 @@ class xKI(ptModifier):
+
+
+ # New stuff begins here. ---------------------------------------------
+
+ # A quick rgrep didn't turn up the definition of PtGetLocalizedString,
+ # only a forward-declaration, so I won't be using it.
+ # Sorry, non-English-speakers. :(
+
+ if string.lower(chatmessage).startswith("/rating x"):
+ if AmICCR:
+ theCensorLevel = xCensor.xRatedX
+ self.ISaveCensorLevel(None)
+ self.IAddRTChat(None, "Wordfilter rating set to X.", kChatSystemMessage)
+ else:
+ theCensorLevel = xCensor.xRatedR
+ self.ISaveCensorLevel(None)
+ self.IAddRTChat(None, "Wordfilter rating set to R.", kChatSystemMessage)
+ return None
+ if string.lower(chatmessage).startswith("/rating r"):
+ theCensorLevel = xCensor.xRatedR
+ self.ISaveCensorLevel(None)
+ self.IAddRTChat(None, "Wordfilter rating set to R.", kChatSystemMessage)
+ return None
+ if string.lower(chatmessage).startswith("/rating pg13") or string.lower(chatmessage).startswith("/rating pg-13"):
+ theCensorLevel = xCensor.xRatedPG13
+ self.ISaveCensorLevel(None)
+ self.IAddRTChat(None, "Wordfilter rating set to PG-13.", kChatSystemMessage)
+ return None
+ if string.lower(chatmessage).startswith("/rating pg"):
+ theCensorLevel = xCensor.xRatedPG
+ self.ISaveCensorLevel(None)
+ self.IAddRTChat(None, "Wordfilter rating set to PG.", kChatSystemMessage)
+ return None
+ if string.lower(chatmessage).startswith("/rating g"):
+ theCensorLevel = xCensor.xRatedG
+ self.ISaveCensorLevel(None)
+ self.IAddRTChat(None, "Wordfilter rating set to G.", kChatSystemMessage)
+ return None
+ if string.lower(chatmessage).startswith("/rating"):
+ # Command recognized, but argument(s) missing or invalid.
+ self.IAddRTChat(None, "Usage: /rating <rating>\nValid ratings are G, PG, PG-13, R.", kChatSystemMessage)
+ return None
+
+ # New stuff ends here. ---------------------------------------------
+
+
_________________
Have Ages, and link to them without bindings.
All times are GMT
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Myst Online: Uru Live™® is the sole property of Cyan Worlds Inc. Copyright 2003-2009 Cyan Worlds, Inc. All Rights reserved.
Myst is a registered trademark of Cyan, Inc. © 1994-2009 Cyan, Inc. The Myst logo is a registered trademark of Cyan, Inc.
Myst and all character names and likenesses are trademarks of Cyan, Inc.
Forums powered by phpBB © 2001 phpBB Group.

