Hi, welcome back.
In this lecture, we will add more functionality to our Twitter chatbot, so let's do that now.
We will add more lines of code to our Twitter chatbot that make it able to follow somebody or follow
all the followers in my account.
So let's begin.
If we open with documents and go to follow all part, we will find that we can use follow with follow
that follow method.
And the following, so we will copy these two lines of code and paste it inside our sublime text, so
so for Falwell and we by dot cursor between two parentheses by those followers that I am sorry I should
change tweet by to T. W..
And inside this Falu followers that follow this will follow all the followers that follow my account.
So this will make me follow all the followers in my account.
But we get an error tweet by that error that we error read only application cannot post the question
here.
What is this mean?
This means that our app at the maybe I cannot write only read which we will change it and the following
by going to the FBI and the click on the setting icon in our app, then updates every mission to be
read and write Arabel as riot police direct messages, which is the third option, which is the better
option to follow or do anything correctly with Twitter a chatbot and the click yes to save several mentions,
then go back to the sublime and build our project again.
And we get the same error.
We can avoid this error by regenerate our tokens at the following and copy these four values, avionic
to.
The consumer, Kay.
Then the FBI secret.
To the consumer sekret.
Then.
The ex is talking.
By regenerate the axis talking and Secrett firstly by clicking unregenerate and axis talking and Secrett.
And Kobe X is talking to the X is talking variable.
Then finally, you will Kobe the X is talk in secret to the X is in secret variable between the two
single codes.
Then build your project to run correctly without any errors.
Now our bison could all bison program all together, chequerboard able to follow all the followers in
my account as I will show you and my account.
My original followers was nine.
Now it will be 19 following nine.
Then following now is 19, as you see.
But you could face some problem or some small issue that if you have a lot of followers.
Or will do some iteration through your code or Twitter chat, but you should use it handle as in documents
of Touhy by Python Library.
So we will copy this, that code from that weepie documents and bust it and.
Sublime text avoid an error caused by iterations of our code called limit or red limit error.
So our function will be the following.
We will make these two four loops turn it into a comments by adding a dash before every two, four,
every line in our code.
Then best the code of the function of lamet handled at the following.
So the F limit underscore handled between two parentheses kurzer column while true tri unit causer the
next except htwe by the thread limit time the sleep will make it one hundred.
I afraid to make it 10.
Milliseconds only and the follow up will add after the function for follower and limited handled Htwe
by.
That kurzer, FBI dot followers dot items Mazard.
If the followers, not friends, count less than six, we will remove this line of code.
We don't need it and bought time by some module or Python library to use its sleep method in our code
and build our mosaic and we get an error.
So to avoid getting this error to Dabu, that limit error and except for stop iteration for the UI loop
and run our project and build it again, and it will run successfully with no errors and ready to avoid
right limit error.
So you don't worry if you have much follower's as it will sleep for 10 milliseconds between right limit
errors.
Now I will return the functionality of following the followers to my Chabert as the following, so I
will remove the comment they and cut these lines of code and paste after the limit hand function as
the following.
But firstly I will build our project to ensure of the correctness of these lines of code.
My project or the weather shadbolt run correctly without any kind of errors, and we will try new functionality
that could be added to our post that unfollow all fours or specific followers.
As you like.
But if you want to follow specific followers, you must pacify these followers inside the Toubon entities
of DMSO between to sing.
Of course this method called for war dot and follow.
Also, we can like or unlike a specific tweet I kobie ID which the last part of the you are out of the
tweet and it is.
And int or integer.
So I would bet that inside.
If I don't create.
Favorite Massoud.
So if I don't create underscore favourite's.
Method and insight, the method parentheses between two single codes that we tied at will like this
to it and run the code again to run.
Correct.
And if we go to my account to the tweet that I like it.
We will find that that we have won like before and won like now from me, then Will has to like it had
won like before and now it had to like.
Now I want to organize our code to be more concise, more readable and fast to run.
And more readable for any programs, so I will take the two for loops and make it inside our.
Lamet handled.
Function to make our code more professional and concise and more readable.
I will remove the duplication in code as a follow and then run out and build it again to avoid any errors
in our code to run correctly and without any errors.
Now, I will add another function that, unlike a tweet by its ID at the following, I want to unlike
this tweet, I will use the ID of the tweet with another method called API Destroy, underscore February
as a following and rebuild our project to run it again.
And it will run correctly without any errors.
And we will check our account and the tweet by the idea that we addressed or entered between the two
single codes inside the parentheses of the API destroy underscore favorite method.
And we will find that our tweet is unliked, have no likes by.
Now you can refer to that weepie documents and recap it well and design your post correctly with many
of other functionalities without overload the Twitter API servers, or reveal your keys or tokens or
secrets and maintain the data of other users safe and secure and make your code ethical and responsible
without any harm to anybody.
So at this point, we it's the end of this lecture.
Hope you enjoyed this picture and get all of that.
Thanks for being here and thanks for watching and see you in the next video at the next section.