Better name/chat filtering #141
Replies: 50 comments 1 reply
-
This would be great! |
Beta Was this translation helpful? Give feedback.
-
@DillonB07 Any progress on this, there are increased reports of people using bad/toxic names |
Beta Was this translation helpful? Give feedback.
-
Sorry, I’ve been a little busy with irl stuff. I’ll see if I have time to start it later today. I don’t think it should be too hard, so hopefully it’ll only take an hour or two.
… On 1 Jun 2022, at 22:11, Coder Gautam ***@***.***> wrote:
@DillonB07 <https://github.com/DillonB07> Any progress on this, there are increased reports of people using bad/toxic names
—
Reply to this email directly, view it on GitHub <https://github.com/codergautam/swordbattle.io/issues/120#issuecomment-1144140567>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AUAPGD7SUKZRANMQL54M7XLVM7GWLANCNFSM5WTR57ZA>.
You are receiving this because you were mentioned.
|
Beta Was this translation helpful? Give feedback.
-
Make sure to take your time. No need to feel rushed! |
Beta Was this translation helpful? Give feedback.
-
Yes, I was just checking in, take your time |
Beta Was this translation helpful? Give feedback.
-
Thanks.
I’m having a little trouble with promises and async functions, so I might try and setup a Python server on Replit to send the requests through.
… On 2 Jun 2022, at 23:59, Coder Gautam ***@***.***> wrote:
Yes, I was just checking in, take your time
—
Reply to this email directly, view it on GitHub <https://github.com/codergautam/swordbattle.io/issues/120#issuecomment-1145420522>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AUAPGD7JWZAL2I2AR7KJ4T3VNE4DTANCNFSM5WTR57ZA>.
You are receiving this because you were mentioned.
|
Beta Was this translation helpful? Give feedback.
-
I've spent a few hours and made no progress. I'm really confused by JS promises and asyncio. I did a little research and it really didn't help. My issue is that I'm using |
Beta Was this translation helpful? Give feedback.
-
Anyone able to help with this please? |
Beta Was this translation helpful? Give feedback.
-
@DillonB07 If you're putting fetch in a normal function, you would have to do something like this:
|
Beta Was this translation helpful? Give feedback.
-
But can you not use a replit server? It would be a pain if it goes down and I don't want to depend on other personal servers. |
Beta Was this translation helpful? Give feedback.
-
Yes, that's what I did @codergautam. The issue came when returning the response from the function as I get a promise not the json. |
Beta Was this translation helpful? Give feedback.
-
Can you send me your code? If you want to do this as a function, here's how I would do it:
And then it can be called like
|
Beta Was this translation helpful? Give feedback.
-
Oh, ok. I'll see if I can rework it and if I can't, I'll send what I have. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Alright, also you shouldn't be needing fetch api anyways, just use the node.js client library https://developers.perspectiveapi.com/s/docs-sample-requests (scroll down a bit to Node.js) If you want I can try doing that |
Beta Was this translation helpful? Give feedback.
-
Yeah, I tried that as well. |
Beta Was this translation helpful? Give feedback.
-
Sorry I have a few more errands to do, might take a few more hours |
Beta Was this translation helpful? Give feedback.
-
No problem. I’ll probably be here for a few more hours so lmk when you’re available if you want to do it today.
… On 5 Jun 2022, at 16:42, Coder Gautam ***@***.***> wrote:
Sorry I have a few more errands to do, might take a few more hours
—
Reply to this email directly, view it on GitHub <https://github.com/codergautam/swordbattle.io/issues/120#issuecomment-1146836275>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AUAPGD7MKT3WZZQF4XIDP2DVNTDFJANCNFSM5WTR57ZA>.
You are receiving this because you were mentioned.
|
Beta Was this translation helpful? Give feedback.
-
Hey sorry I completely forgot about this can we do it tomm since I'm out of town today. Sorry |
Beta Was this translation helpful? Give feedback.
-
Possibly.
I’m not guaranteeing it as I’m quite busy, but I should be free 6-7PM BST tomorrow if that works for you.
If you send me the code snippet that you wrote when you have time, I can try and do a little work on it myself.
… On 6 Jun 2022, at 16:04, Coder Gautam ***@***.***> wrote:
Hey sorry I completely forgot about this can we do it tomm since I'm out of town today.
Sorry
—
Reply to this email directly, view it on GitHub <https://github.com/codergautam/swordbattle.io/issues/120#issuecomment-1147549896>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AUAPGD6MXHF2SFY6QHR25A3VNYHPLANCNFSM5WTR57ZA>.
You are receiving this because you were mentioned.
|
Beta Was this translation helpful? Give feedback.
-
Good luck! |
Beta Was this translation helpful? Give feedback.
-
Thanks.
It’s going great!
```zsh
~/Documents/GitHub/swordbattle.io (main ✗) node .
Prof undefined
Connected to database
Loaded 2 evolutions
36
server started
Unhandled Rejection at: Promise Promise {
<rejected> Error: Error: Error: Request failed with status code 400
at Client.<anonymous> (/Users/dillonbarnes/Documents/GitHub/swordbattle.io/node_modules/@conversationai/perspectiveapi-js-client/dist/api.js:104:23)
at Generator.throw (<anonymous>)
at rejected (/Users/dillonbarnes/Documents/GitHub/swordbattle.io/node_modules/@conversationai/perspectiveapi-js-client/dist/api.js:5:65)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
} reason: Error: Error: Error: Request failed with status code 400
at Client.<anonymous> (/Users/dillonbarnes/Documents/GitHub/swordbattle.io/node_modules/@conversationai/perspectiveapi-js-client/dist/api.js:104:23)
at Generator.throw (<anonymous>)
at rejected (/Users/dillonbarnes/Documents/GitHub/swordbattle.io/node_modules/@conversationai/perspectiveapi-js-client/dist/api.js:5:65)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
exiting cleanly...
exited cleanly
```
Note to self. Never send console logs through an email.
… On 7 Jun 2022, at 16:33, Coder Gautam ***@***.***> wrote:
const { Client } = ***@***.***/perspectiveapi-js-client");
const client = new Client(process.env.PERSPECTIVE_API_KEY);
const checkForProfanity = (word) => {
// const result = await perspective.analyze(word, {attributes: ["unsubstantial", "spam", "toxicity"], languages: ["en"]});
return client.getScores(word, {languages:[ "en"]}).TOXICITY > 0.85;
};
checkForProfanity("smth bad").then((result) => {
console.log(result);
});
Good luck!
—
Reply to this email directly, view it on GitHub <https://github.com/codergautam/swordbattle.io/issues/120#issuecomment-1148832886>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AUAPGD35LWSVSNZL6MPXCHTVN5TVTANCNFSM5WTR57ZA>.
You are receiving this because you were mentioned.
|
Beta Was this translation helpful? Give feedback.
-
That was a stupid error. My API key had a different name in my /Users/dillonbarnes/Documents/GitHub/swordbattle.io/index.js:47
checkForProfanity("smth bad").then((result) => {
^
TypeError: checkForProfanity(...).then is not a function
at Object.<anonymous> (/Users/dillonbarnes/Documents/GitHub/swordbattle.io/index.js:47:31)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
Node.js v17.4.0 And when I go to just a regular |
Beta Was this translation helpful? Give feedback.
-
Wait my bad try this:
|
Beta Was this translation helpful? Give feedback.
-
That’s what I did try. It will always return false because the request hasn’t finished. Try putting swear words/phrases in it and you’ll see.
… On 7 Jun 2022, at 19:18, Coder Gautam ***@***.***> wrote:
Wait my bad try this:
const { Client } = ***@***.***/perspectiveapi-js-client");
const client = new Client(process.env.PERSPECTIVE_API_KEY);
const checkForProfanity = (word) => {
// const result = await perspective.analyze(word, {attributes: ["unsubstantial", "spam", "toxicity"], languages: ["en"]});
return client.getScores(word, {languages:[ "en"]}).TOXICITY > 0.85;
};
console.log(checkForProfanity("smth bad"));
—
Reply to this email directly, view it on GitHub <https://github.com/codergautam/swordbattle.io/issues/120#issuecomment-1149014331>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AUAPGD6Z7SFHUND4A7FWXLLVN6G7FANCNFSM5WTR57ZA>.
You are receiving this because you were mentioned.
|
Beta Was this translation helpful? Give feedback.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
-
My bad, try this one. Pretty sure this works.
|
Beta Was this translation helpful? Give feedback.
-
Moved to discussions! |
Beta Was this translation helpful? Give feedback.
-
Yeah, I've completely messed things up. Not got a clue what I've done, but this is open to anyone else now. Here's a Uses conversationai/perspectiveapi-js-client PM me on the forum for the API key: @DillonB07 const { Client } = require("@conversationai/perspectiveapi-js-client");
const client = new Client(process.env.PERSPECTIVE_API_KEY);
const checkForProfanity = async (word, profanitySensitivity = 0.75) => {
// const result = await perspective.analyze(word, {attributes: ["unsubstantial", "spam", "toxicity"], languages: ["en"]});
return new Promise((resolve, reject) => {
try {
resolve(client.getScores(word, { languages: ["en"] }));
} catch (e) {
reject(e);
}
}).then((result) => result.TOXICITY > profanitySensitivity);
}; The above code snippet will send a return a boolean of whether the message is toxic. The sensitivity can be passed into the function as a float. It'll have a default of I tried to implement this in a I'm not entirely sure whether filtering is needed in |
Beta Was this translation helpful? Give feedback.
-
I'll be using Google's Perspective API to improve the chat/username filtering. Any score greater than 70% will be blocked. We can fine-tune the percentage later if needed.
Perspective API
Perspective Docs
This will be worked on in https://github.com/DillonB07/swordbattle.io/
Beta Was this translation helpful? Give feedback.
All reactions