(cobra bots) add a utility class to factor out the common bots features (heartbeat) and move cobra to sentry bot to use it

This commit is contained in:
Benjamin Sergeant
2020-04-16 14:49:49 -07:00
parent ccfd196863
commit 0f5d15aa11
6 changed files with 364 additions and 257 deletions

View File

@ -0,0 +1,42 @@
/*
* IXCobraBot.h
* Author: Benjamin Sergeant
* Copyright (c) 2020 Machine Zone, Inc. All rights reserved.
*/
#pragma once
#include <ixcobra/IXCobraConfig.h>
#include <stddef.h>
#include <json/json.h>
#include <mutex>
#include <condition_variable>
#include <queue>
#include <map>
namespace ix
{
using OnBotMessageCallback = std::function<bool(const Json::Value&,
const bool verbose,
std::atomic<bool>&)>;
class CobraBot
{
public:
CobraBot() = default;
int64_t run(const CobraConfig& config,
const std::string& channel,
const std::string& filter,
const std::string& position,
bool verbose,
size_t maxQueueSize,
bool enableHeartbeat,
int runtime);
void setOnBotMessageCallback(const OnBotMessageCallback& callback);
private:
OnBotMessageCallback _onBotMessageCallback;
};
}