2024-01-02 03:45:06 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* dtranslatebot Discord Translate Bot
|
|
|
|
* Copyright (C) 2023-2024 Syping
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
* are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* This software is provided as-is, no warranties are given to you, we are not
|
|
|
|
* responsible for anything with use of the software, you are self responsible.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef SETTINGS_H
|
|
|
|
#define SETTINGS_H
|
|
|
|
#include <cstdint>
|
|
|
|
#include <mutex>
|
2024-01-11 21:49:01 +01:00
|
|
|
#include <string>
|
2024-01-02 03:45:06 +01:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace bot {
|
|
|
|
namespace settings {
|
2024-01-12 11:18:15 +01:00
|
|
|
struct target {
|
|
|
|
std::string target;
|
|
|
|
std::string webhook;
|
|
|
|
};
|
2024-01-02 03:45:06 +01:00
|
|
|
struct channel {
|
|
|
|
uint64_t id;
|
|
|
|
std::string source;
|
2024-01-12 11:18:15 +01:00
|
|
|
std::vector<bot::settings::target> targets;
|
2024-01-02 03:45:06 +01:00
|
|
|
};
|
|
|
|
struct guild {
|
|
|
|
uint64_t id;
|
|
|
|
std::vector<bot::settings::channel> channel;
|
|
|
|
};
|
|
|
|
struct translate {
|
|
|
|
std::string hostname;
|
|
|
|
uint16_t port;
|
|
|
|
std::string url;
|
|
|
|
bool tls;
|
|
|
|
std::string apiKey;
|
|
|
|
};
|
|
|
|
|
|
|
|
class settings {
|
|
|
|
public:
|
2024-01-17 12:38:16 +01:00
|
|
|
uint16_t get_avatar_size();
|
2024-01-02 03:45:06 +01:00
|
|
|
bot::settings::channel* get_channel(bot::settings::guild *guild, uint64_t channel_id);
|
2024-01-12 11:18:15 +01:00
|
|
|
bot::settings::channel* get_channel(uint64_t guild_id, uint64_t channel_id);
|
2024-01-02 03:45:06 +01:00
|
|
|
bot::settings::guild* get_guild(uint64_t guild_id);
|
|
|
|
bot::settings::translate* get_translate();
|
|
|
|
const std::string get_token();
|
2024-01-12 12:53:16 +01:00
|
|
|
bool is_translatebot(uint64_t webhook_id);
|
2024-01-02 03:45:06 +01:00
|
|
|
void lock();
|
|
|
|
bool parse(const std::string &filename);
|
|
|
|
void unlock();
|
|
|
|
|
|
|
|
private:
|
2024-01-17 12:38:16 +01:00
|
|
|
uint16_t m_avatarSize;
|
2024-01-02 03:45:06 +01:00
|
|
|
std::recursive_mutex m_mutex;
|
|
|
|
std::vector<bot::settings::guild> m_guilds;
|
2024-01-12 12:53:16 +01:00
|
|
|
bot::settings::translate m_translate;
|
2024-01-02 03:45:06 +01:00
|
|
|
std::string m_token;
|
2024-01-12 12:53:16 +01:00
|
|
|
std::vector<uint64_t> m_webhookIds;
|
2024-01-02 03:45:06 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-17 12:38:16 +01:00
|
|
|
#endif // SETTINGS_H
|