-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathnotifiers.hh
98 lines (88 loc) · 1.97 KB
/
notifiers.hh
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#pragma once
#include <string>
#include "sol/sol.hpp"
#include "sclasses.hh"
#include <set>
#include "sqlwriter.hh"
#include "fmt/core.h"
class Notifier
{
public:
Notifier(sol::table& data)
{
d_minMinutes = data.get_or("minMinutes", 0);
data["minMinutes"] = sol::lua_nil;
}
Notifier(bool)
{
}
virtual ~Notifier() = default;
virtual void alert(const std::string& message) = 0;
std::string getNotifierName() { return d_notifierName; }
void bulkAlert(const std::string& textBody);
void bulkDone();
protected:
std::map<std::string, time_t> d_times;
bool d_verbose = false;
std::string d_notifierName;
private:
std::set<std::string> d_reported, d_prevReported;
std::set<std::string> d_oldEnough, d_prevOldEnough;
int d_minMinutes=0;
};
class InternalWebNotifier : public Notifier
{
public:
InternalWebNotifier() : Notifier(false)
{
// d_verbose=true;
d_notifierName="InternalWeb";
}
std::map<std::string, time_t> getTimes()
{
return d_times;
}
void alert(const std::string& message) {}
};
class SQLiteWriterNotifier : public Notifier
{
public:
SQLiteWriterNotifier() : Notifier(false)
{
d_notifierName="SQLiteWriter";
}
void alert(const std::string& message) override;
};
class PushoverNotifier : public Notifier
{
public:
PushoverNotifier(sol::table data);
void alert(const std::string& message) override;
private:
std::string d_user, d_apikey;
};
class NtfyNotifier : public Notifier
{
public:
NtfyNotifier(sol::table data);
void alert(const std::string& message) override;
private:
std::string d_auth, d_url, d_topic;
};
class EmailNotifier : public Notifier
{
public:
EmailNotifier(sol::table data);
void alert(const std::string& message) override;
private:
std::string d_from, d_to;
ComboAddress d_server;
};
class TelegramNotifier : public Notifier
{
public:
TelegramNotifier(sol::table data);
void alert(const std::string& message) override;
private:
std::string d_botid, d_apikey, d_chatid;
};