diff --git a/inc/crypt.h b/inc/crypt.h index 6ccd06d..8de0e00 100644 --- a/inc/crypt.h +++ b/inc/crypt.h @@ -19,4 +19,5 @@ public: private: std::map chatKeyMap; bool dirty = true; + std::string self; }; diff --git a/src/crypt.cpp b/src/crypt.cpp index d5f9b0d..7020a9e 100644 --- a/src/crypt.cpp +++ b/src/crypt.cpp @@ -35,6 +35,10 @@ std::string Crypt::encryptForChat(int64_t chat, const std::string& message) { .setFDMode(Y::SubProcess::FD::ALL, Y::SubProcess::FDMode::Pipe) ; + if(!self.empty()) { + builder.addArgs({"--encrypt-to", self}); + } + std::unique_ptr proc = builder.start(); std::string out; @@ -113,8 +117,12 @@ void Crypt::load() { std::string key; int64_t chat = 0; in >> chat >> key; - if(chat && !key.empty()) { - chatKeyMap[chat] = key; + if(!key.empty()) { + if(chat == 0) { + self = key; + } else { + chatKeyMap[chat] = key; + } } } dirty = false;