static void Main(string[] args)
 {
     using (HttpClient client = new HttpClient())
     {
         try
         {
             TokenBucket bucket = new TokenBucket(60, 60);
             RedditBot   bot    = new RedditBot(
                 ConfigurationManager.AppSettings["clientId"],
                 ConfigurationManager.AppSettings["clientSecret"],
                 ConfigurationManager.AppSettings["RedditUsername"],
                 ConfigurationManager.AppSettings["RedditPassword"],
                 client,
                 bucket,
                 "0.01",
                 "PrettyNiceBot",
                 "sandboxtest/comments",
                 "body");
             bot.StartBot();
             Console.ReadKey();
         }
         catch (TooLowCapacityException exception)
         {
             Console.WriteLine($"Error thrown '{exception.Message}' ");
         }
         catch (FaultyLoginException exception)
         {
             Console.WriteLine($"Error thrown '{exception.Message}' ");
         }
     }
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var         elegigle = new BotStratergy();
            TokenBucket tb       = new TokenBucket(30, 60);

            using (var bot = new RedditBot(tb, elegigle))
            {
                elegigle.Run(bot);
                Console.ReadKey();
            }
        }
 /// <summary>
 /// A reddit bot (constructor).
 /// </summary>
 /// <param name="clientId">the Id of the client</param>
 /// <param name="clientSecret">the Secret of the client</param>
 /// <param name="username">the reddit username</param>
 /// <param name="password">the reddit password</param>
 /// <param name="client">a HttpClient to be used</param>
 /// <param name="tokenBucket">a tokenBucket, from the class TokenBucket</param>
 /// <param name="botVersion">the version of the bot</param>
 /// <param name="botName">the name of the bot</param>
 /// <param name="subreddit">the subreddit that should be searcehd for information, example: "sandboxtest", different paths can be used, for example /new, /comments</param>
 /// <param name="jsonValue">the json key that is to be used</param>
 public RedditBot(string clientId, string clientSecret, string username, string password, HttpClient client, TokenBucket tokenBucket, string botVersion, string botName, string subreddit, string jsonValue)
 {
     _clientId     = clientId;
     _clientSecret = clientSecret;
     _username     = username;
     _password     = password;
     _tokenBucket  = tokenBucket;
     _botVersion   = botVersion;
     _botName      = botName;
     _subreddit    = subreddit;
     _jsonKey      = jsonValue;
     _client       = client;
 }
Exemplo n.º 4
0
 public CommentHandler(TokenBucket tbucket, HttpClient authenticatedClient)
 {
     _tbucket = tbucket;
     _client  = authenticatedClient;
 }
Exemplo n.º 5
0
 public RedditBot(TokenBucket tb, BotStratergy stratergy)
 {
     _bucket = tb;
     strat   = stratergy;
 }