Remove unnecessary function
This commit is contained in:
parent
105a34b61f
commit
5ec8d5d364
10
index.js
10
index.js
|
@ -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`);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue