1
00:00:00,630 --> 00:00:01,930
Hi, welcome back.

2
00:00:02,040 --> 00:00:12,020
In this lecture, we will add more functionality to our Twitter chatbot, so let's do that now.

3
00:00:12,030 --> 00:00:23,130
We will add more lines of code to our Twitter chatbot that make it able to follow somebody or follow

4
00:00:23,490 --> 00:00:27,250
all the followers in my account.

5
00:00:27,450 --> 00:00:29,580
So let's begin.

6
00:00:30,480 --> 00:00:45,420
If we open with documents and go to follow all part, we will find that we can use follow with follow

7
00:00:45,780 --> 00:00:47,910
that follow method.

8
00:00:48,740 --> 00:01:00,140
And the following, so we will copy these two lines of code and paste it inside our sublime text, so

9
00:01:00,650 --> 00:01:12,710
so for Falwell and we by dot cursor between two parentheses by those followers that I am sorry I should

10
00:01:13,130 --> 00:01:16,990
change tweet by to T. W..

11
00:01:17,540 --> 00:01:28,160
And inside this Falu followers that follow this will follow all the followers that follow my account.

12
00:01:28,310 --> 00:01:34,720
So this will make me follow all the followers in my account.

13
00:01:34,880 --> 00:01:44,270
But we get an error tweet by that error that we error read only application cannot post the question

14
00:01:44,270 --> 00:01:44,630
here.

15
00:01:44,750 --> 00:01:46,110
What is this mean?

16
00:01:46,820 --> 00:01:58,220
This means that our app at the maybe I cannot write only read which we will change it and the following

17
00:01:58,340 --> 00:02:07,610
by going to the FBI and the click on the setting icon in our app, then updates every mission to be

18
00:02:07,910 --> 00:02:16,250
read and write Arabel as riot police direct messages, which is the third option, which is the better

19
00:02:16,250 --> 00:02:27,520
option to follow or do anything correctly with Twitter a chatbot and the click yes to save several mentions,

20
00:02:27,650 --> 00:02:32,360
then go back to the sublime and build our project again.

21
00:02:35,190 --> 00:02:36,890
And we get the same error.

22
00:02:39,630 --> 00:02:50,070
We can avoid this error by regenerate our tokens at the following and copy these four values, avionic

23
00:02:50,340 --> 00:02:50,850
to.

24
00:02:52,090 --> 00:02:53,410
The consumer, Kay.

25
00:02:55,780 --> 00:02:58,630
Then the FBI secret.

26
00:03:00,510 --> 00:03:02,700
To the consumer sekret.

27
00:03:06,910 --> 00:03:07,420
Then.

28
00:03:08,400 --> 00:03:09,660
The ex is talking.

29
00:03:15,350 --> 00:03:23,690
By regenerate the axis talking and Secrett firstly by clicking unregenerate and axis talking and Secrett.

30
00:03:25,000 --> 00:03:29,820
And Kobe X is talking to the X is talking variable.

31
00:03:30,010 --> 00:03:40,180
Then finally, you will Kobe the X is talk in secret to the X is in secret variable between the two

32
00:03:40,180 --> 00:03:41,140
single codes.

33
00:03:43,180 --> 00:03:48,010
Then build your project to run correctly without any errors.

34
00:03:48,280 --> 00:03:56,050
Now our bison could all bison program all together, chequerboard able to follow all the followers in

35
00:03:56,050 --> 00:04:00,940
my account as I will show you and my account.

36
00:04:01,360 --> 00:04:05,150
My original followers was nine.

37
00:04:05,700 --> 00:04:10,360
Now it will be 19 following nine.

38
00:04:10,780 --> 00:04:15,640
Then following now is 19, as you see.

39
00:04:16,030 --> 00:04:24,730
But you could face some problem or some small issue that if you have a lot of followers.

40
00:04:25,520 --> 00:04:37,580
Or will do some iteration through your code or Twitter chat, but you should use it handle as in documents

41
00:04:37,580 --> 00:04:41,050
of Touhy by Python Library.

42
00:04:41,420 --> 00:04:49,040
So we will copy this, that code from that weepie documents and bust it and.

43
00:04:50,290 --> 00:04:59,740
Sublime text avoid an error caused by iterations of our code called limit or red limit error.

44
00:05:01,180 --> 00:05:05,250
So our function will be the following.

45
00:05:06,160 --> 00:05:17,110
We will make these two four loops turn it into a comments by adding a dash before every two, four,

46
00:05:17,110 --> 00:05:18,910
every line in our code.

47
00:05:19,300 --> 00:05:26,610
Then best the code of the function of lamet handled at the following.

48
00:05:27,070 --> 00:05:38,520
So the F limit underscore handled between two parentheses kurzer column while true tri unit causer the

49
00:05:39,100 --> 00:05:50,800
next except htwe by the thread limit time the sleep will make it one hundred.

50
00:05:51,920 --> 00:05:54,440
I afraid to make it 10.

51
00:05:55,610 --> 00:06:05,900
Milliseconds only and the follow up will add after the function for follower and limited handled Htwe

52
00:06:05,900 --> 00:06:06,410
by.

53
00:06:07,940 --> 00:06:13,220
That kurzer, FBI dot followers dot items Mazard.

54
00:06:14,760 --> 00:06:23,050
If the followers, not friends, count less than six, we will remove this line of code.

55
00:06:23,310 --> 00:06:32,220
We don't need it and bought time by some module or Python library to use its sleep method in our code

56
00:06:32,340 --> 00:06:35,990
and build our mosaic and we get an error.

57
00:06:36,030 --> 00:06:47,190
So to avoid getting this error to Dabu, that limit error and except for stop iteration for the UI loop

58
00:06:47,880 --> 00:06:57,720
and run our project and build it again, and it will run successfully with no errors and ready to avoid

59
00:06:57,720 --> 00:06:59,220
right limit error.

60
00:06:59,370 --> 00:07:09,840
So you don't worry if you have much follower's as it will sleep for 10 milliseconds between right limit

61
00:07:09,840 --> 00:07:10,400
errors.

62
00:07:10,640 --> 00:07:19,410
Now I will return the functionality of following the followers to my Chabert as the following, so I

63
00:07:19,410 --> 00:07:29,940
will remove the comment they and cut these lines of code and paste after the limit hand function as

64
00:07:29,940 --> 00:07:30,560
the following.

65
00:07:30,840 --> 00:07:39,390
But firstly I will build our project to ensure of the correctness of these lines of code.

66
00:07:43,590 --> 00:07:53,520
My project or the weather shadbolt run correctly without any kind of errors, and we will try new functionality

67
00:07:53,970 --> 00:08:02,570
that could be added to our post that unfollow all fours or specific followers.

68
00:08:03,490 --> 00:08:04,360
As you like.

69
00:08:05,310 --> 00:08:15,720
But if you want to follow specific followers, you must pacify these followers inside the Toubon entities

70
00:08:15,720 --> 00:08:19,080
of DMSO between to sing.

71
00:08:19,090 --> 00:08:24,540
Of course this method called for war dot and follow.

72
00:08:25,110 --> 00:08:36,450
Also, we can like or unlike a specific tweet I kobie ID which the last part of the you are out of the

73
00:08:36,450 --> 00:08:38,130
tweet and it is.

74
00:08:39,360 --> 00:08:41,400
And int or integer.

75
00:08:43,160 --> 00:08:45,530
So I would bet that inside.

76
00:08:46,640 --> 00:08:50,090
If I don't create.

77
00:08:51,110 --> 00:08:52,880
Favorite Massoud.

78
00:08:54,680 --> 00:08:59,050
So if I don't create underscore favourite's.

79
00:08:59,780 --> 00:09:08,480
Method and insight, the method parentheses between two single codes that we tied at will like this

80
00:09:08,480 --> 00:09:11,450
to it and run the code again to run.

81
00:09:11,450 --> 00:09:11,950
Correct.

82
00:09:11,960 --> 00:09:18,320
And if we go to my account to the tweet that I like it.

83
00:09:19,820 --> 00:09:30,140
We will find that that we have won like before and won like now from me, then Will has to like it had

84
00:09:30,140 --> 00:09:35,060
won like before and now it had to like.

85
00:09:35,480 --> 00:09:43,250
Now I want to organize our code to be more concise, more readable and fast to run.

86
00:09:44,410 --> 00:09:55,060
And more readable for any programs, so I will take the two for loops and make it inside our.

87
00:09:56,310 --> 00:09:57,600
Lamet handled.

88
00:09:59,630 --> 00:10:06,230
Function to make our code more professional and concise and more readable.

89
00:10:06,830 --> 00:10:18,440
I will remove the duplication in code as a follow and then run out and build it again to avoid any errors

90
00:10:18,440 --> 00:10:22,730
in our code to run correctly and without any errors.

91
00:10:22,780 --> 00:10:32,300
Now, I will add another function that, unlike a tweet by its ID at the following, I want to unlike

92
00:10:32,300 --> 00:10:42,740
this tweet, I will use the ID of the tweet with another method called API Destroy, underscore February

93
00:10:42,950 --> 00:10:47,030
as a following and rebuild our project to run it again.

94
00:10:47,900 --> 00:10:50,990
And it will run correctly without any errors.

95
00:10:51,620 --> 00:11:03,530
And we will check our account and the tweet by the idea that we addressed or entered between the two

96
00:11:03,560 --> 00:11:09,800
single codes inside the parentheses of the API destroy underscore favorite method.

97
00:11:10,070 --> 00:11:16,190
And we will find that our tweet is unliked, have no likes by.

98
00:11:17,600 --> 00:11:26,540
Now you can refer to that weepie documents and recap it well and design your post correctly with many

99
00:11:26,540 --> 00:11:35,540
of other functionalities without overload the Twitter API servers, or reveal your keys or tokens or

100
00:11:35,540 --> 00:11:45,650
secrets and maintain the data of other users safe and secure and make your code ethical and responsible

101
00:11:45,680 --> 00:11:48,200
without any harm to anybody.

102
00:11:49,370 --> 00:11:53,300
So at this point, we it's the end of this lecture.

103
00:11:53,810 --> 00:11:56,690
Hope you enjoyed this picture and get all of that.

104
00:11:56,720 --> 00:12:03,860
Thanks for being here and thanks for watching and see you in the next video at the next section.
