Remove unnecessary function

This commit is contained in:
Noman 2018-09-06 05:59:41 -04:00
parent 105a34b61f
commit 5ec8d5d364
No known key found for this signature in database
GPG Key ID: ACD1C4A99857525C
1 changed files with 3 additions and 7 deletions

View File

@ -9,24 +9,20 @@ const bridge = new MatrixRiotBridge();
bridge.init().then(([whisperUtils]) => {
whisperUtils.getPublicKey().then(publicKey => {
function isMe(sig) {
return publicKey === sig;
}
whisperUtils.send(CHANNEL, 'Bot is alive');
whisperUtils.listen(CHANNEL).then(
subscription => {
subscription.on('data', ({ payload, sig, timestamp, topic }) => {
const [, [message]] = decodeStatusPayload(payload);
const me = isMe(sig);
const name = me ? 'Bot' : sig.slice(0, 10);
const isMe = publicKey === sig;
const name = isMe ? 'Bot' : sig.slice(0, 10);
console.log('From:', name, 'at', timestamp);
console.log('Topic:', topic);
console.log('Message:', message, '\n');
if (!me) {
if (!isMe) {
whisperUtils.send(CHANNEL, `${message} back`);
}
});