Jump to content

PY Function - Global Block Words


Recommended Posts

M2 Download Center

This is the hidden content, please
( Internal )

 

def Run(self):
	res = self.GetText()
	#res = self.inputValue.GetText()  ## your input value
	try:
		fHandle = app.OpenTextFile("locale/en/block_words_python.txt")
		w = app.GetTextFileLineCount(fHandle)
	except IOError:
		dbg.LogBox("Error: Loading words !")
		app.Abort()

	for j in xrange(w):
		lc = app.GetTextFileLine(fHandle, j)
		c = str(lc).split("\t")
		if len(c) == 0 or not c[0]:
			continue	
		elif res == c[0]:
			chat.AppendChat(chat.CHAT_TYPE_INFO, "[SYSTEM] Blocked words were introduced!")
			return

locale/en/block_words_python.txt

text0
text1
text2
text3
text4
text5
text6
text7
text8
text9
text10
text11
text12
text13
text14
text15

 

  • Love 6
Link to comment
Share on other sites

8 minutes ago, galet said:

Hi,

Thanks, but why don't simply use the insult.txt file ? This is exactly the same thing (or almost)

Bro, this is not for words with offense etc, insult function is loaded from source It has nothing to do with it.

With this script you can add any tape you want to check text such as:
- Box friendship request
- Box declaring war
- Box quest input
- Any other box that includes a InputValue

You need only change:

szText = self.GetText()

With this:

szText = self.yourInputValue.GetText() # Obtaining the text that you wrote in the same box

You can play a lot with this little code is funny.

  • Love 1
Link to comment
Share on other sites

  • Honorable Member

I do not know what is this and why need this, but the code is ugly a little. And what those commented lines are?
If you release smthg do not put inside unnecessary codes.

Here is a little code which is much sexier:

 

import app, chat
szText = "banword"

fHandle = app.OpenTextFile("locale/en/block_words_python.txt")
if not fHandle:
	return False

if szText in [app.GetTextFileLine(fHandle, i).strip() for i in xrange(app.GetTextFileLineCount(fHandle))]
	chat.AppendChat(chat.CHAT_TYPE_INFO, "[SYSTEM] Blocked words were introduced!")
	return

 

Edited by xP3NG3Rx
Idiot code tag, why not fix someone this fcking shit...?
  • Love 1
Link to comment
Share on other sites

6 hours ago, xP3NG3Rx said:

I do not know what is this and why need this, but the code is ugly a little. And what those commented lines are?
If you release smthg do not put inside unnecessary codes.

Here is a little code which is much sexier:

 


import app, chat
szText = "banword"

fHandle = app.OpenTextFile("locale/en/block_words_python.txt")
if not fHandle:
	return False

if szText in [app.GetTextFileLine(fHandle, i).strip() for i in xrange(app.GetTextFileLineCount(fHandle))]
	chat.AppendChat(chat.CHAT_TYPE_INFO, "[SYSTEM] Blocked words were introduced!")
	return

 

Much better now, thanks for comment dude sexy.:lol:

 

And.. yeah code tag is *fcking shit*...

  • Love 1
Link to comment
Share on other sites

  • 4 months later...
  • 11 months later...

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.