mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-11 16:49:22 +08:00
packages.missgram: fix
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user