1
00:00:00,810 --> 00:00:07,920
In this video, we will write a script which goes through the posts over the last two days in a somber

2
00:00:07,920 --> 00:00:13,620
edit of and the script looks for specific words in the title of each post.

3
00:00:14,220 --> 00:00:19,590
And if it finds that words, it replies to that particular post.

4
00:00:20,430 --> 00:00:27,840
For example, we could write a book which looks for posts about Christmas, and if the bot finds that

5
00:00:27,840 --> 00:00:32,970
the title contains the words Christmas, then the boat says, Merry Christmas.

6
00:00:33,780 --> 00:00:34,590
So let's do that.

7
00:00:35,310 --> 00:00:41,730
We first need to import the pro library and then creates a related instance, as I'm doing in here.

8
00:00:43,350 --> 00:00:49,490
Then we said that we want to look through the posts of a subreddit, so we need to create a subreddit.

9
00:00:49,860 --> 00:01:00,600
Let's say I'm working on the glassblowing subreddits, then we want to loop over four posts in sub Reddit.

10
00:01:00,670 --> 00:01:01,650
That's new.

11
00:01:03,930 --> 00:01:07,800
So this gives us this page.

12
00:01:07,800 --> 00:01:15,510
So Reddit dot com slash or slash glassblowing slash new, which you get when you press that new bots

13
00:01:15,510 --> 00:01:18,000
are there to sort posts by new.

14
00:01:18,960 --> 00:01:28,200
Although this doesn't matter much because we will filter these by the last 48 hours anyway.

15
00:01:28,920 --> 00:01:32,250
So the codes goes mostly like in the previous video.

16
00:01:32,520 --> 00:01:40,860
We create the current time with dates time from date, time, import date time.

17
00:01:43,340 --> 00:01:48,680
We also get the first time, so I explain this in the previous video, so you should watch that video

18
00:01:48,680 --> 00:01:50,990
if you didn't dance so already.

19
00:01:52,340 --> 00:01:54,500
Then we calculated the death toll.

20
00:01:55,470 --> 00:02:05,550
And then we had a conditional which check if there is less or equal to 24 hours.

21
00:02:06,120 --> 00:02:09,479
This time we were working on 48 hours, so two days.

22
00:02:10,169 --> 00:02:16,050
And then what we do is we have a lease where we append these posts.

23
00:02:16,950 --> 00:02:20,190
This time we don't want to append anything in the lease.

24
00:02:20,190 --> 00:02:22,380
We don't want to write anything in a file.

25
00:02:22,620 --> 00:02:23,730
So we remove that.

26
00:02:25,260 --> 00:02:31,050
What we want to do is if we want to check if the word Christmas.

27
00:02:34,000 --> 00:02:37,270
It's in force, though, it's the title.

28
00:02:38,260 --> 00:02:44,530
But be careful because you should be lowering that title.

29
00:02:44,710 --> 00:02:51,100
So the title could be, for example, as you see, this is Christmas with a Capital C, so you want

30
00:02:51,100 --> 00:02:58,450
to make the entire title lowercase and then you can check for lowercase Christmas in the lowercase title.

31
00:02:59,410 --> 00:03:11,890
So if Christmas in both the sides of the lower, then we see post dot replying, Hey, Christmas is

32
00:03:11,890 --> 00:03:12,700
coming.

33
00:03:13,300 --> 00:03:15,850
No, I'll koman this out.

34
00:03:16,300 --> 00:03:18,970
Before I do that, I first check if.

35
00:03:20,500 --> 00:03:29,370
I got the actual post title correctly, so let me run this, I also forgot to import Chinese.

36
00:03:31,030 --> 00:03:32,620
So import events run again.

37
00:03:34,480 --> 00:03:37,480
Yes, so we gave the correct post, as we see in the title.

38
00:03:38,020 --> 00:03:42,070
Now let's try to add a reply to that post.

39
00:03:43,330 --> 00:03:47,680
So run, and let's check now this post.

40
00:03:50,890 --> 00:03:51,080
Yeah.

41
00:03:51,300 --> 00:03:53,980
Hate Christmas is coming, so my comment is here.

42
00:03:54,790 --> 00:03:56,020
It was added just now.

43
00:03:56,350 --> 00:04:04,630
And that is how you add comments to a post on Reddit if you want to add comments to existing comments.

44
00:04:05,170 --> 00:04:15,190
Then what you need to do is instead of that, you want to iterate for comments, then post those comments.

45
00:04:16,480 --> 00:04:26,980
And if, let's say the word is coming in comments, that's body so common that it gives you the actual

46
00:04:26,980 --> 00:04:28,150
taste of the comment.

47
00:04:28,450 --> 00:04:31,000
If that's words, is in the comments.

48
00:04:31,150 --> 00:04:39,430
So for example, in these comments that we just added lowercase, so let's just lower the case or the

49
00:04:39,430 --> 00:04:41,830
comments than we do.

50
00:04:41,990 --> 00:04:43,930
Comments that reply?

51
00:04:46,040 --> 00:04:48,440
Yeah, it's coming.

52
00:04:50,530 --> 00:04:51,070
Run that.

53
00:04:53,390 --> 00:04:59,480
And of course, we do have this limitation of credits that we have to wait now seven minutes.

54
00:05:00,110 --> 00:05:01,910
So I'll try after seven minutes.

55
00:05:03,120 --> 00:05:06,420
Yes, or seven minutes have passed, so let's try this again.

56
00:05:09,710 --> 00:05:12,020
It seems to be working, let's check.

57
00:05:15,210 --> 00:05:21,960
Yes, so this is my comment, added, add this to an existing comment in a post in a subreddit.

58
00:05:23,830 --> 00:05:30,580
So that is a complete code on how to reply to a post and how to reply to a comment in a post on Reddit.

59
00:05:30,910 --> 00:05:31,370
Thank you.

60
00:05:31,410 --> 00:05:32,230
I'll see you later.

