Weather oracle
git clone https://github.com/byteball/bot-example
cd bot-example
npm install
cp .env.testnet .envheadlessWallet.readSingleAddress(address => {
my_address = address;
console.error('my_address', address)
});
eventBus.on('text', (from_address, text) => {
text = text.trim();
const device = require('ocore/device.js');
const args = text.toLowerCase().split(':');
if (args.length === 2){
switch (args[0]) {
case 'berlin':
case 'moscow':
case 'helsinki':
case 'washington':
if(parseInt(args[1]) <= Date.now()){
console.error('dateNow', Date.now());
device.sendMessageToDevice(from_address, 'text', "Incorrect time");
}else {
arrQueue.push({city: args[0], time: args[1], device_address: from_address});
device.sendMessageToDevice(from_address, 'text', "ok");
}
break;
default:
device.sendMessageToDevice(from_address, 'text', "City not support");
break;
}
}else {
device.sendMessageToDevice(from_address, 'text', "Incorrect command");
}
});Last updated
Was this helpful?