-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
71 lines (58 loc) · 2.47 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Threading;
using Reddit.Controllers;
namespace RedditBot
{
//Get your auth key here. https://not-an-aardvark.github.io/reddit-oauth-helper/
public class Program
{
public static string BotUsername = "MyRedditUsername";
static string[] accountInfo = new string[] { "MyAppId","MyRefreshToken","MyAccessToken" };
static string[] keywords = new string[] { "words", "to", "search", "for", "etc.." };
static void Main(string[] args)
{
WorkFlow workFlow = new WorkFlow(accountInfo);
Console.WriteLine("\n \n Press Escape at any time to exit. \n");
while (true)
{
Thread.Sleep(500);
Console.WriteLine("Enter the Url of the post");
string urlPost = string.Empty;
while (string.IsNullOrEmpty(urlPost))
{
urlPost = Console.ReadLine();
if (string.IsNullOrEmpty(urlPost))
{
Console.WriteLine("url may not be empty");
Console.WriteLine("Enter the Url of the post");
}
}
Console.WriteLine("Enter your comment");
string comment = string.Empty;
while (string.IsNullOrEmpty(comment))
{
comment = Console.ReadLine();
if (string.IsNullOrEmpty(comment))
{
Console.WriteLine("Comment may not be empty");
Console.WriteLine("Enter your comment");
}
}
Post post = workFlow.ParsePostFromUrl(urlPost);
if(post == null)
{
Console.WriteLine("Url is incorrect, or your bot is unauthorized to post here. \n" +
" Check your reddit messages if you believe the link is correct, otherwise please try again \n" +
"with a new link.");
Console.WriteLine("------------------------");
Thread.Sleep(500);
continue;
}
string response = workFlow.MassReply(post, keywords, comment);
Console.WriteLine(response);
Thread.Sleep(500);
Console.WriteLine("------------------------");
}
}
}
}