packages.missgram: fix

This commit is contained in:
2025-12-28 15:40:25 +08:00
parent f7deb945ae
commit 3a34d1e962
3 changed files with 10 additions and 10 deletions

View File

@@ -2,17 +2,17 @@
namespace missgram
{
void db_write(std::string misskey_note, int telegram_message_id);
std::optional<int> db_read(std::string misskey_note);
void db_write(std::string misskey_note, std::int32_t telegram_message_id);
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
{
std::string Secret;
std::string TelegramBotToken;
int TelegramChatId;
int ServerPort;
std::int64_t TelegramChatId;
std::int16_t ServerPort;
std::string dbPassword;
} inline config;
}

View File

@@ -1,16 +1,16 @@
# include <missgram.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
({.user = "missgram", .password = config.dbPassword, .host = "127.0.0.1", .dbname = "missgram"});
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;
auto&& conn = sqlgen::postgres::connect

View File

@@ -1,7 +1,7 @@
# include <missgram.hpp>
# 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;
@@ -25,5 +25,5 @@ std::optional<int> missgram::tg_send(std::string text, std::optional<int> replyI
}
// 返回消息 ID
if (message) return message->messageId;
if (message) return message->messageId; else return {};
}