Older/Server/WeChatContext/CorporationContext.h
amass 83b0ff4369
All checks were successful
Deploy Docker Images / Build dockerfile and Server deploy (push) Successful in 18s
Deploy / Build (push) Successful in 3m0s
add exit command.
2024-11-10 18:33:39 +08:00

45 lines
1.3 KiB
C++

#ifndef __CORPORATIONCONTEXT_H__
#define __CORPORATIONCONTEXT_H__
#include "Singleton.h"
#include <boost/asio/steady_timer.hpp>
#include <boost/beast/http/string_body.hpp>
class CorporationContext : public std::enable_shared_from_this<CorporationContext> {
friend class Amass::Singleton<CorporationContext>;
public:
enum MessageType {
Text,
Markdown,
};
using RequestType = boost::beast::http::request<boost::beast::http::string_body>;
void sendMessage(MessageType type, const std::string &message);
void start();
/**
* @brief
*
* @param request
* @example curl -H "Content-Type: application/json" -X POST -d '{"user_id": "123", "msg":"OK!" }'
* https://amass.fun/notify
*/
void notify(const RequestType &request);
protected:
CorporationContext(boost::asio::io_context &ioContext);
void updateAccessToken();
private:
boost::asio::io_context &m_ioContext;
boost::asio::steady_timer m_timer;
std::string m_accessToken;
constexpr static auto host = "qyapi.weixin.qq.com";
constexpr static auto port = "443";
constexpr static auto corpid = "ww1a786851749bdadc";
constexpr static auto corpsecret = "LlyJmYLIBOxJkQxkhwyqNVf550AUQ3JT2MT4yuS31i0";
constexpr static auto agentid = 1000002;
};
#endif // __CORPORATIONCONTEXT_H__