mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 00:49:42 +08:00
packages.missgram: fix
This commit is contained in:
@@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
namespace missgram
|
namespace missgram
|
||||||
{
|
{
|
||||||
void db_write(std::string misskey_note, int telegram_message_id);
|
void db_write(std::string misskey_note, std::int32_t telegram_message_id);
|
||||||
std::optional<int> db_read(std::string misskey_note);
|
std::optional<std::int32_t> db_read(std::string misskey_note);
|
||||||
|
|
||||||
std::optional<int> tg_send(std::string text, std::optional<int> replyId = {});
|
std::optional<std::int32_t> tg_send(std::string text, std::optional<std::int32_t> replyId = {});
|
||||||
|
|
||||||
struct Config
|
struct Config
|
||||||
{
|
{
|
||||||
std::string Secret;
|
std::string Secret;
|
||||||
std::string TelegramBotToken;
|
std::string TelegramBotToken;
|
||||||
int TelegramChatId;
|
std::int64_t TelegramChatId;
|
||||||
int ServerPort;
|
std::int16_t ServerPort;
|
||||||
std::string dbPassword;
|
std::string dbPassword;
|
||||||
} inline config;
|
} inline config;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# include <missgram.hpp>
|
# include <missgram.hpp>
|
||||||
# include <sqlgen/postgres.hpp>
|
# include <sqlgen/postgres.hpp>
|
||||||
|
|
||||||
struct Record { std::string misskey_note; int telegram_message_id; };
|
struct Record { std::string misskey_note; std::int32_t telegram_message_id; };
|
||||||
|
|
||||||
void missgram::db_write(std::string misskey_note, int telegram_message_id)
|
void missgram::db_write(std::string misskey_note, std::int32_t telegram_message_id)
|
||||||
{
|
{
|
||||||
auto&& conn = sqlgen::postgres::connect
|
auto&& conn = sqlgen::postgres::connect
|
||||||
({.user = "missgram", .password = config.dbPassword, .host = "127.0.0.1", .dbname = "missgram"});
|
({.user = "missgram", .password = config.dbPassword, .host = "127.0.0.1", .dbname = "missgram"});
|
||||||
sqlgen::write(conn, Record{misskey_note, telegram_message_id});
|
sqlgen::write(conn, Record{misskey_note, telegram_message_id});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<int> missgram::db_read(std::string misskey_note)
|
std::optional<std::int32_t> missgram::db_read(std::string misskey_note)
|
||||||
{
|
{
|
||||||
using namespace sqlgen::literals;
|
using namespace sqlgen::literals;
|
||||||
auto&& conn = sqlgen::postgres::connect
|
auto&& conn = sqlgen::postgres::connect
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# include <missgram.hpp>
|
# include <missgram.hpp>
|
||||||
# include <tgbot/tgbot.h>
|
# include <tgbot/tgbot.h>
|
||||||
|
|
||||||
std::optional<int> missgram::tg_send(std::string text, std::optional<int> replyId)
|
std::optional<std::int32_t> missgram::tg_send(std::string text, std::optional<std::int32_t> replyId)
|
||||||
{
|
{
|
||||||
using namespace biu::literals;
|
using namespace biu::literals;
|
||||||
|
|
||||||
@@ -25,5 +25,5 @@ std::optional<int> missgram::tg_send(std::string text, std::optional<int> replyI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 返回消息 ID
|
// 返回消息 ID
|
||||||
if (message) return message->messageId;
|
if (message) return message->messageId; else return {};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user