[MUSIC]
>> Welcome, everybody. My name is
Michael Jolly. I'm bald, bearded.
Today is a special stream.
We are sponsored by Azure, our good friends in blue.
Everybody knows that watches this stream,
that our minds are the biggest trolls
and I found this service on Azure,
talked to them about it.
I'm like, I want to implement this,
that we're going to replace the mods with Azure's AI.
We had those people who come into chat sometimes that are like,
want to buy some followers and subscribers and
click this link, www.phishyourpassword.com/followers.
Our moderators are really
good about cleaning that out of Twitch chat,
the problem is messages that usually show up over here,
it's already on the screen and so moderating
the message in chat doesn't make it not show up over here.
This would allow us to put in some filters and say, hey,
if some weirdo is trying to do that,
don't make it show up in Twitch chat,
on the screen, we don't want to give them the time or day.
Let's start at the beginning.
Moderator is going to this URL. Let's bring that up.
Noose, but dang, noose.
All of those are in the same SDK as of
complete package but you can get individual ones too.
We're going to moderate it there.
Let's bring that into something else though.
Let's do, I can't think of any place we would,
I'm just going to put it in there and say
new files, call it Moderator.
Let me copy this and see.
I'm just going to paste it in there.
That doesn't look like TypeScript.
Well, you're wrong because JavaScript is valid TypeScript,
so probably I want to import content moderator client.
If this is a moderator,
let's say this is an abstract moderator.
In this, that's where I think it can do private.
Let's do this. All this but dang, dang here.
Content moderator be this dot.
Oh, yeah.
What is this? Oh, private here too.
In that, let's initialize that junk.
We'll do this over here and say this.cognitiveServiceCredentials,
we don't have to equal that many times
mainly a gun quit hit the L key.
This is really hard to read actually,
this is not a very accessible theme.
We'll initialize those mamma gemas and then
here's where we're actually going to want to do
the work but this is wrong.
A content moderator key.
Let's call it Azure_Content_Moderator_Key.
Content_Moderator_ Endpoint equals.
We'll have to add that to the.env file but we
also need to update, is it the Docker?
No, Docker doesn't need that. What needs that?
Oh, the GitHub action that deploys it.
We'll need to say, hey,
you need to send over these things
because this runs in a container.
Send that equals to
secrets dot and we'll just call it the same
thing, secrets.that but dang.
That should have our GitHub action ready for us.
Azure functions ready to go.
If I get this,
let's take in a chat message.
Over here, let's come up here and pretend this is all written.
We're going to say import Moderator
from moderator. Oh you are now lucky.
No, it's not used. Up here in
the constructor let's initialize that thing.
Moderator.net; is that right?
We're going to initialize in the constructor.
Constant booger, we'll change that or maybe
we won't, equals Moderator.review.
We're going to be passing in a string.
Let's say message is a string.
Do I want to create a type here or
should I just create it somewhere else?
Let's create it with the rest of our types.
A new file. Let's call it a moderationResult.
I don't know of a better way. I hate naming things result.
Export type, moderationResult.
Original message maybe it's a string clean message.
Do I have a barrel in this?
Export all from moderationResult.
You are not sorted alphabetically.
How dare you. We're going to need a promise of moderation.
It's going to return a moderationResult.
Then over here we'll know modResult.
It's not booger anymore.
We're going to pass in the message, we'll review it here.
We done and got the results,
return something like this,
clean. I always just do that.
Let's do something like constant is blocked and
constant clean message equals but dang.
Get rid of this, result.
What is result? Give me a type.
It's still an any. You dirty dog.
So Bolting, just a big object.
Next, that's going to be a string detected is a string subtype,
it's a string index, it's a number.
Let's make that like global up here.
Constant moderation, thresh hold equals 0.5,
Category 2 and Category 3.
Let's do log level.info.
We're going to log out if,
let's say if is blocked,
then log to the console.
It's basically a logging to the console.
But dang dash but dang,
so we'll write out the three scores with dashes and then say,
but dang the message.
If it's blocked, we'll know why and I'm just thinking that's more
important right now while we're testing
because that 0.5 maybe low.
The debugger, like it should start logging some stuff
here if it's listening. That looks right.
If not modResult is blocked,
do all this rigmarole here.
Do all that. Return and then
change this and say modResult.cleanMessage.
That way if it like removed
any personally identifiable junk
or even corrected your spelling but dang.
Result classification, possibly offensive scored really high.
It's funny that like it's actually explicit or suggestive mature
didn't score that high but possibly offensive,
did. That's perfect.
That's going to show us is blocked, true.
That's awesome but that worked.
You can come in here and add features to our chatbot.
Come on, push it up to Azure.
Logging in to Azure CLI, do it.
Once it deploys, we'll switch over to Azure and make
sure that the version is, was it 1024?
Let's see, where's that?
Right there, run with it.
Running. Hey, time-out.
Oh there it is. It's done.
It's running, perfect.
Just like that, we have solved moderation for our channel.
Hit user that Azure command.
Go check it out, go learn more about it.
[MUSIC]