mirror of
https://github.com/MeshEnvy/lobbs.git
synced 2026-11-03 11:32:25 +01:00
feat(meshtastic): extract LoBBS plugin library
This commit is contained in:
1 parent
1f7ded8f3f
commit
5bffe8d259
124 files changed
+10907
-39
No files matched your search
@@ -0,0 +1,54 @@
|
||||
#if !MESHTASTIC_EXCLUDE_LOBBS
|
||||
|
||||
#include "serialize.h"
|
||||
#include "LoBBSHooks.h"
|
||||
#include <lodb/LoDB.h>
|
||||
|
||||
#include "LoBBSStackGuard.h"
|
||||
|
||||
static void lobbsDisplayGeneric(const LoScalar &record, std::string &lineOut)
|
||||
{
|
||||
std::string title;
|
||||
std::string body;
|
||||
record.getString(LODB_F_TITLE, title);
|
||||
record.getString(LODB_F_DESCRIPTION, body);
|
||||
if (title.empty() && body.empty()) {
|
||||
lineOut.clear();
|
||||
return;
|
||||
}
|
||||
if (title.empty()) {
|
||||
lineOut = body;
|
||||
return;
|
||||
}
|
||||
if (body.empty()) {
|
||||
lineOut = title;
|
||||
return;
|
||||
}
|
||||
lineOut = title + " (" + body + ")";
|
||||
}
|
||||
|
||||
bool lobbsSerializePlainText(const LoBBSCommandCtx &ctx, const LoBBSResponse &resp, std::string &out)
|
||||
{
|
||||
out.clear();
|
||||
if (!resp.ok) {
|
||||
out = resp.error;
|
||||
return !out.empty();
|
||||
}
|
||||
for (const LoScalar &rec : resp.records) {
|
||||
std::string line;
|
||||
lobbsDisplayGeneric(rec, line);
|
||||
LoScalar shown;
|
||||
shown.setString(LODB_F_TITLE, line);
|
||||
lobbsApplyFilter("display_human", const_cast<LoBBSCommandCtx &>(ctx), shown, rec);
|
||||
line.clear();
|
||||
shown.getString(LODB_F_TITLE, line);
|
||||
if (line.empty())
|
||||
continue;
|
||||
if (!out.empty())
|
||||
out.push_back('\n');
|
||||
out += line;
|
||||
}
|
||||
return !out.empty();
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user