deltachat / deltachat-node

Email-based instant messaging for Node.js.
GNU General Public License v3.0
45 stars 11 forks source link

best way to relay msg? #398

Closed cracker0dks closed 4 years ago

cracker0dks commented 4 years ago

I want to create a bot to relay messages to others.

Don't working:

dc.on('DC_EVENT_INCOMING_MSG', (chatIdFrom, msgId) => {
    const msg = dc.getMessage(msgId);
    dc.sendMessage(otherChatId, msg);
}

Error: 400 0 peerstate for [email] missing, cannot encrypt

If I relay like this:

dc.on('DC_EVENT_INCOMING_MSG', (chatIdFrom, msgId) => {
    const msg = dc.getMessage(msgId);
    const msgTxt = msg.getText();
    dc.sendMessage(otherChatId, msgTxt );
}

In this case I also get the log: Error: 100 0 peerstate for [email] missing, cannot encrypt

but not a 400 and It works. But for text only ofc. I don't want to catch all types of different messages so is there a easy way to relay the hole msg obj? Thanks :)

Simon-Laux commented 4 years ago

I would reconstruct it, otherwise your sending a existing message again, which can in theory make problems later. Also it might make sense to expand the forward message api to optionaly don't include the notice that it was forwarded

cracker0dks commented 4 years ago

ok, ty