Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function updateWidget() {
- console.log("Обновляю виджет...")
- var tops = []
- for (i=1;i<200000;i++) {
- if(acc.users[i]) {
- if(acc.users[i].level < 4 && acc.users[i].block_top == false) {
- tops.push({id: i, idvk: acc.users[i].id, lvl: acc.users[i].donate});
- }
- }
- }
- tops.sort(function(a, b) {
- if (b.lvl > a.lvl) return 1
- if (b.lvl < a.lvl) return -1
- return 0
- })
- var script = {
- title: `Топ лучших игроков`,
- head: [
- {
- text: 'Ник'
- },
- {
- text: 'Деньги',
- align: 'right'
- },
- {
- text: 'Снежинки❄️',
- align: 'right'
- }
- ],
- body: []
- }
- for (var g = 0; g < 10; g++) {
- if (tops.length > g) {
- let ups = g;
- ups += 1;
- if(g <= 8) ups = `${ups}`
- if(g == 9) ups = `10`
- script.body.push([
- {
- icon_id: `id${tops[g].idvk}`,
- text: `${acc.users[tops[g].id].prefix}`,
- url: `vk.com/id${tops[g].idvk}`
- },
- {
- text: `${spaces(acc.users[tops[g].id].balance)}$`
- },
- {
- text: `❄️${spaces(tops[g].lvl)}`
- },
- ])
- }
- }
- requests.post({url: 'https://api.vk.com/method/appWidgets.update', form:{
- v: '5.95',
- type: 'table',
- code: `return ${JSON.stringify(script)};`,
- access_token: '' // Специальный токен с уровнем доступа app_widgets
- }
- },
- function(err, resp, body) {
- console.log(body)
- }
- )
- console.log("Виджет обновлён!")
- }
- updateWidget()
- setInterval(updateWidget, 99999)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement