17 using System.Collections.Concurrent;
18 using System.Collections.Generic;
28 private const int RateLimit = 30;
31 private DateTime _resetTime;
33 private readonly
bool _liveMode;
34 private readonly
object _sync =
new object();
39 public ConcurrentQueue<Notification>
Messages {
get;
set; }
48 Messages =
new ConcurrentQueue<Notification>();
51 _resetTime =
default(DateTime);
62 public bool Email(
string address,
string subject,
string message,
string data, PyObject headers)
64 return Email(address, subject, message, data, headers.ConvertToDictionary<
string,
string>());
75 public bool Email(
string address,
string subject,
string message,
string data =
"", Dictionary<string, string> headers =
null)
93 public bool Sms(
string phoneNumber,
string message)
113 public bool Web(
string address,
object data, PyObject headers)
115 return Web(address, data, headers.ConvertToDictionary<
string,
string>());
124 public bool Web(
string address,
object data =
null, Dictionary<string, string> headers =
null)
144 public bool Telegram(
string id,
string message,
string token =
null)
170 var now = DateTime.UtcNow;
171 if (now > _resetTime)
176 _resetTime = now.Add(TimeSpan.FromHours(1));
179 if (_count < RateLimit)