I make a bot for VK on Node.js. Can not get the ID of the author of the last message of the conference. Returns undefined. Do not understand why
'use strict'; (o) => { let comp = ['Π·Π°Π²ΠΎΡΠΎΠΆΡΡΡΠΈΠΉ','ΡΠ΅ΠΊΡΡ','ΡΠΈΠΊΠ°ΡΠ½ΠΈΠΉ','ΡΠ°ΠΊΠΈΠΉ Π·Π²Π°Π±Π»ΠΈΠ²ΠΈΠΉ','ΠΊΡΠ°ΡΠ°Π²ΡΠΈΠΊ','ΠΊΡΠ΅Π°ΡΠΈΠ²Π½ΠΈΠΉ','ΡΠΎΠΌΠ°Π½ΡΠΈΡΠ½ΠΈΠΉ','ΡΠΎΠ»ΠΎΠ΄Π΅Π½ΡΠΊΠΈΠΉ','Π·Π°Π³Π°Π΄ΠΊΠΎΠ²ΠΈΠΉ','Π±Π΅Π·Π΄ΠΎΠ³Π°Π½Π½ΠΈΠΉ','ΡΠΊΡΠΎΠΌΠ½ΡΠ³Π°','ΠΏΡΠΈΠ²Π°Π±Π»ΠΈΠ²ΠΈΠΉ','Π½Π΅Π·ΡΡΠ²Π½ΡΠ½Π½ΠΈΠΉ','ΡΠ΅ΡΡΠΈΡΠ½ΠΈΠΉ','ΡΠ°ΠΌΠΈΠΉ-ΡΠ°ΠΌΠΈΠΉ',]; var lenComp = comp.length - 1; var choise = parseInt((Math.random() * (lenComp - 0 + 1)) + 0); var gans = comp[choise]; o['$'].callMethod('messages.getHistory', {offset: 1, count: 1, peer_id: 2000000112}, (ans) => { try { ans = JSON.parse(ans)['response']['items']; o['bot'].send(`🍏 ${['user_id']}`, o['body'], {}); } catch(e) { o['bot'].send('ΠΠΎΠΌΠ°Π½Π΄Π° ΠΏΡΠ°ΡΡΡ ΡΡΠ»ΡΠΊΠΈ Π² ΠΊΠΎΠ½ΡΠ΅ΡΠ΅Π½ΡΡΡΡ
', o['body'], {}); } }); }
items
here andundefined
- Alexey Shimansky