nhammond129 / ch.py

Python library for connecting to Chatango chat servers.
21 stars 20 forks source link

Adding the banned words section to the ch.py? #37

Closed AcePokeMaster closed 10 years ago

AcePokeMaster commented 10 years ago

Well not sure if anyone wants the banned words section in this ch.py besides me. I have the code for it so if anyone wants it added to the nullspeaker ch.py just comment and I'll make a pull request.

asl97 commented 10 years ago

anon: !say somebadword > chatango > !say * > send to everyone bot get !say * and send * > chatango > * > send to everyone

so it would just say * so just check for * in the message, no need for the banned list

AcePokeMaster commented 10 years ago

They could do:

self.getRoom("examplegroup").message("cuss word here")

If the banned word is in the group

asl97 commented 10 years ago

wow, you giving eval to everyone? D: ether way bot: send badword > chatango > * send to everyone

no harm done, just block the user who try to do this

AcePokeMaster commented 10 years ago

@asl97 You aren't looking at the full issue at that post I posted. You can use that as a cmd like this just an example:

if used_prefix and cmd == "roommsg" and args:
    roomname, xmsg = args.lower().split(" ", 1)
    if any(word for word in self.getRoom(roomname).bannedwords if word.lower() in xmsg):
        room.message("You can't use any banned words to send to that chat.")
   else:
       self.getRoom(roomname).message(xmsg)
asl97 commented 10 years ago

i see lots of problem with that code for such a small amount of code

1 indent error 2 if i type just the used_prefix and roommsg with a single length args, it will crash LOL

AcePokeMaster commented 10 years ago

@asl97 It was just an example. I don't want any code stealing noobs to steal good codes.

asl97 commented 10 years ago

@AcePokeMaster you really think noobs can't fix indent error? after using python for 1 week, anyone can fix indent error and that coding style is slow, anyone who would copy it would be dumb

AcePokeMaster commented 10 years ago

@asl97 You never know. And I know a ton of people who would steal that code just because they don't how to code it themselves.

asl97 commented 10 years ago

the only reason why anyone want to use that is to bypass the ban place on them in a room

it's a useless cmd that allow spam

AcePokeMaster commented 10 years ago

@asl97 Actually it's more useful than you think. There are several reasons people use that cmd. To send a message to the chat, if a user is flood banned and needs to send a message to chat, etc

asl97 commented 10 years ago

a user would only get flood banned if he or she is spamming or typing too fast and don't know how to join what they want to say in one big message so it's kind of their fault

like i said, it's a cmd for bypassing ban whether it's flood ban, flag ban or ip ban

AcePokeMaster commented 10 years ago

Btw just a note @asl97 and @nullspeaker , two other people(apollo9 and AlThamen) and myself would like this feature added to this ch.py.

asl97 commented 10 years ago

if someone want it add it, it shouldn't use more than the amount stated below on a 1.87ghz cpu

i am against adding something as useless as this but i think i am fair enough to give a maximum implementation time stated below

6 word long: 0.06ms
1000 word long: 0.6ms
10000 word long bannedlist: 2.7ms

since the best i gotten is stated below and mind you, it was make under 10 second, not optimize at all, i can most likely half that if i spend some time on it

6 words long bannedlist: 0.02 ms
1000 word long bannedlist: 0.4ms
10000 word long bannedlist: 1.8 ms

the time for the code above in that pastebin is stated below and mind you, it was the best case scenario speed

6 words long bannedlist: 0.28ms
1000 word long bannedlist: 25.ms
10000 word long bannedlist: 179 ms
AcePokeMaster commented 10 years ago

@asl97 Why would any chat have over 1,000 banned words list? Let alone have 100 banned words list. And Alec would probably ban the chat owner for abusing chatango for adding so many words.

asl97 commented 10 years ago

@AcePokeMaster my room as over 20000 mod and alec doesn't know or care about, for all you know someone might get a bot to join a room with lots of banned word

if the banned list implementation can't scale well then it should never been added

the pastebin for 1m words is: 22395.932912826538ms = 22 second+

my implementation is: 201.80439949035645ms = less than 1 second

AcePokeMaster commented 10 years ago

@asl97 Your room only has 2,345 mods.

Maybe Alec would take a look at my idea on a limit for how many mods and banned words you can add.

asl97 commented 10 years ago

@AcePokeMaster my other room, my secret benchmark room which you don't know about

AcePokeMaster commented 10 years ago

@asl97 And I don't really care about ;)

asl97 commented 10 years ago

@AcePokeMaster since you don't care about the issue anymore, it shouldn't be added

AcePokeMaster commented 10 years ago

@asl97 I meant about your chat with 23,000 mods. -_- Stupid.

asl97 commented 10 years ago

@AcePokeMaster now see who's rude

and yea, i make you said that :P

AcePokeMaster commented 10 years ago

@asl97 How mature...

AcePokeMaster commented 10 years ago

@asl97 Lol jk. That was very immature of you. I would expect somebody at your age would have the decency to be mature and treat others with respect.

asl97 commented 10 years ago

@AcePokeMaster you were the one who keep saying i am rude and keep going off topic and then we both keep dragging on and get even more off topic

then keep flooding everyone emails, and they will get mad at us cause of you and me

AcePokeMaster commented 10 years ago

@asl97 There's no rules saying we can't be off-topic. ;)

asl97 commented 10 years ago

@AcePokeMaster our chatting here and other issue has cause over 20 emails to be send to piks, nullspeaker, Apollo9, AlThamen, you and me and lots of other people

are you happy now?

piks commented 10 years ago

@AcePokeMaster im not sure if you understand but when the bot sends a message to chatango, if the message contains a bad word it replaces the word with * self.getRoom(roomname).message(bannedword) would be send the message "*" not bannedword

AcePokeMaster commented 10 years ago

@piks You're not understanding what I'm saying. I'll explain it with a example. So let's say a user tries to send a message to another chat and in the chat has the banned word "douchebag" and within that message has that word that the user posted in the the other chat the bot woulf check to see if that message contains any banned words in the chat they are sending to and if so the bot would not allow that message to sent to there.

AcePokeMaster commented 10 years ago

Also the other people want banned words section want the addWord function too. I don't think it's possible for the removeWord because the word would just go to an asterisk LOL

piks commented 10 years ago

@AcePokeMaster i see no point of that in a bot,

AcePokeMaster commented 10 years ago

@piks Well maybe a moderation bot? Hmmm. It could add inappropiate words to the chat's banned word list to prevent users from saying those words

AlThamen commented 10 years ago

@asl97 a reasonable person would use gmail or hotmail(not sure about horrible ol yahoo tho) as it merges all emails sent by the same email as one huge topic session o.o so np np , even though this topic isnt game changing or anything, it could still serve useful and polite as to help filter out "badwords" incase chat rules may contain "any usage of banned words may result in ban" or something of the such, so as stated, its not some sort of huge necessary thing but it does have its own usefulness

piks commented 10 years ago

@AcePokeMaster i ment the return if the banned word is in the message not the adding banned words, the bros have a dynamic banned words list that doesnt use chat bannedwords it uses admin set dynamic ones

AcePokeMaster commented 10 years ago

@piks Ah I gotcha ya. What do you mean by dynamic banned words list, do you mean you get the bot to make its own banned word list and use that instead of the chat?

AcePokeMaster commented 10 years ago

@asl97 I improved the rcmd_bw. And this is what it looks like now in this bpaste http://bpaste.net/show/ujs2NjsSiSxYzMo20Xpb/

AcePokeMaster commented 10 years ago

@asl97 WAIT NOT THAT ONE LOL. I made a mistake on line 2. This is the correct one http://bpaste.net/show/Dy8uYmtw2hwnzgsr93nB/

AcePokeMaster commented 10 years ago

@asl97 If I could edit I would have changed the url. .-. But I got Piks opinion on that code and said it was bulky so I made it shorter and I ended up with this http://bpaste.net/show/Dip0FO9J6vYfdzrzVlfs/

asl97 commented 10 years ago

@AcePokeMaster there is no onBannedWordsUpdated, if you just throw that it, it would just crash so -OVER 9000!

@AlThamen a reasonable person might do that but a smart person would roll out their own mail server, you can never trust google or anyone not to read your emails

AcePokeMaster commented 10 years ago

@asl97 Saw that and that was very childish for a 17 year old. But getting back to topic, in ch.py they called it def onBannedWordsUpdated but I'm gonna just take the d and in that code I'll probably remove the args in the EventCalled section so it'll look like this:

self._callEvent("onBannedWordsUpdate")
asl97 commented 10 years ago

@AcePokeMaster https://github.com/Nullspeaker/ch.py/search?q=onBannedWordsUpdate&ref=cmdform

there is no onBannedWordsUpdate on this ch.py, what part of it would error if you put the code in don't you understand

AcePokeMaster commented 10 years ago

@asl97 I meant version 1.3 of the ch.py. That is just part of the banned word section obviously if you didn't know that. So if I made a pull request that would be the rcmd_bw

asl97 commented 10 years ago

@AcePokeMaster then go make one why don't you? or are you just going to say your browser wouldn't let you? i wonder if there anyone else who let their browser control what they are allow to do :P

AcePokeMaster commented 10 years ago

@asl97 I can't make one because I'm using a outdated browser. But I did use bpaste to make a one: http://bpaste.net/show/EDw5mUMSwU47elrMI6Zs/

asl97 commented 10 years ago

@AcePokeMaster that's not how you submit a patch if you aren't able to make a pull request, go look up how to make a diff patch

AcePokeMaster commented 10 years ago

@asl97 I can't do that either.

AcePokeMaster commented 10 years ago

@asl97 Meh I'm just closing this issue because once again this is getting us nowhere. I'll just add it to my own version.

asl97 commented 10 years ago

@AcePokeMaster even a beginner can manually make a simple diff patch, it's not even that hard, you are just lazy to look up how

AcePokeMaster commented 10 years ago

@asl97 I did look it up. My browser will not alow me to do it because it redirects me to error saying my browser is outdated so don't just assume something when you know nothing of what I did. It's very rude.

asl97 commented 10 years ago

@AcePokeMaster are you trying to say that your browser doesn't allow you to even type letters? then how are you even replying to me or are you just dumb? a diff patch is make out of letters, just plain old letters

this is an example of the fix banlist commit in a patch format

--- a/ch.py
+++ b/ch.py
@@ -1142,14 +1142,14 @@ class Room:
     if args[2] == "": return
     target = User(args[2])
     user = User(args[3])
-    self._banlist[user] = {"unid":args[0], "ip":args[1], "target":target, "time
+    self._banlist[target] = {"unid":args[0], "ip":args[1], "target":target, "ti
     self._callEvent("onBan", user, target)

   def _rcmd_unblocked(self, args):
     if args[2] == "": return
     target = User(args[2])
     user=User(args[3])
-    del self._banlist[user]
+    del self._banlist[target]
     self._unbanlist[user] = {"unid":args[0], "ip":args[1], "target":target, "ti
     self._callEvent("onUnban", user, target)

and just paste it on a pastebin like you always do, or are you going to say your browser doesn't allow you to paste too?

AcePokeMaster commented 10 years ago

@asl97 Let me explain this slowly to you. My ipod is very old. When I switch to desktop version it will direct me to error saying it does not support my outdated browser. Github only allows me to do so much on the desktop version on my ipod.