-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
77 lines (69 loc) · 3.18 KB
/
main.cpp
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
#include <fstream>
#include <string>
#include "sleepy_discord/sleepy_discord.h"
#include "key_handler.h"
#include "yks.h"
#include "cloudinary_uploader.h"
class FribotClientClass : public SleepyDiscord::DiscordClient {
public:
using SleepyDiscord::DiscordClient::DiscordClient;
void onMessage(SleepyDiscord::Message message) override {
if (message.channelID.number() == 838515196153823242) {
deleteMessage(message.channelID, message.ID);
}
if (message.startsWith("fb?test")) {
sendMessage(message.channelID,
"Hello " + message.author.username +
", friBot is using C++ from now on.");
}
else if (message.startsWith("fb?yks")) {
Yks yks(message.content);
if (yks.isProblematic() != true) {
sendMessage(message.channelID,
"Yerleştirme puanınız: " + yks.getPlacementPoint() +
", 2020 YKS'ye göre SAY sıralamanız: " +
yks.getPlacementRanking() + "\n" +
"Ham puanınız: " + yks.getPurePoint() +
", 2019 YKS'ye göre SAY sıralamanız: " +
yks.getPlacementRankingByYear(2019));
} else {
sendMessage(message.channelID,
"Hatalı parametre girdiniz. Lütfen diploma notu ve "
"doğru-yanlış "
"bilgilerinizi kontrol ediniz. Mesaj içeriğinde "
"gereksiz -fazla- "
"ögelerin olmamasına dikkat ediniz.");
}
}
else if (message.startsWith("fb?up")) {
CloudinaryUploader uploader(message.attachments.at(0));
if (uploader.isProblematic() != true) {
sendMessage(message.channelID,
"Your image ``" + uploader.getAttachmentFileName() +
"`` has been uploaded successfully, with "
"Public ID: ``" +
uploader.getUploadedImagePublicId() +
"`` and Signature: ``" +
uploader.getUploadedImageSignature() + "``\n<" +
uploader.getUploadedImageUrl() + ">");
} else {
sendMessage(
message.channelID,
"Upload failed. There may be a server-related problem or "
"you may have tried to upload an unsupported file type.");
}
}
}
void onReady(SleepyDiscord::Ready ready_data) override {
updateStatus("berkcakar.dev 👋", 0, SleepyDiscord::online, false);
}
};
int main() {
std::ifstream keyFile{"../api_keys.json"};
KeyHandler keyHandler{keyFile};
FribotClientClass client(keyHandler.getDiscordKey(),
SleepyDiscord::USER_CONTROLED_THREADS);
client.setIntents(SleepyDiscord::Intent::SERVER_MESSAGES,
SleepyDiscord::Intent::SERVER_VOICE_STATES);
client.run();
}