Jump to content

Change chattext by replace function


Recommended Posts

  • Forum Moderator

root/uiChat.py

  • def __SendChatPacket(self, text, type):

root/uiWhisper.py

  • def SendWhisper(self):

Change variable idkwhat with text.

  • Love 3
Link to comment
Share on other sites

16 hours ago, avertuss said:

Hi. How can i edit chat like: if player sent message "hi noob" it will be shown "hi n**b". I know that i should use 


if idkwhat.find("noob") != -1:
			idkwhat = idkwhat.replace('noob', 'n**b')

but idk where should i use that in uichat or idk where. Any ideas? 

Make a array like here :

 Words = ["noob", "l33t", "ggwp"]

 

for v in Words:

 if text.find(v) != -1:

   BWords = text.replace(v, '****')

 

  • Love 1
Link to comment
Share on other sites

  • Forum Moderator
4 hours ago, Kori said:

BWords = text.replace(v, '****')
#text = text.replace(word, word[0] + "*" * (len(word) - 2) + word[-1])
text = text.replace(word, '{first}{filter_char}{last}'.format(
					first = word[0], filter_char = "*" * (len(word) - 2), last = word[-1]))
>>> Don't call me a l******y. 

With that type of replace you'll get asterisks by the length of your specific word, and will show just the first and the last character.

@avertuss Btw you already have CInsultChecker::FilterInsult  (which is used just for server-2-client TPacketGCChat), you can modify/duplicate the functions which are related about it and return the specific string which is detected from sentence and replace it with that method in python.

Link to comment
Share on other sites

1 hour ago, VegaS™ said:

#text = text.replace(word, word[0] + "*" * (len(word) - 2) + word[-1])
text = text.replace(word, '{first}{filter_char}{last}'.format(
					first = word[0], filter_char = "*" * (len(word) - 2), last = word[-1]))
>>> Don't call me a l******y. 

With that type of replace you'll get asterisks by the length of your specific word, and will show just the first and the last character.

@avertuss Btw you already have CInsultChecker::FilterInsult  (which is used just for server-2-client TPacketGCChat), you can modify/duplicate the functions which are related about it and return the specific string which is detected from sentence and replace it with that method in python.

Good code, yes I have typed my code on mobile phone 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

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.