import { VK, Method } from 'vkstatic'
const params = {
token: String (),
groupId: Number ()
}
const vk = new VK ({
...params
})
const bot = async () => {
await new Method ()
.event (response => {
console.log (response.event.event_type)
})
}
bot ()
messages.getDialogs, messages.getConversations
messages.send
let name = prompt("Enter your name:",);
let age = +prompt("Enter your age:",);
var x;
function checkAge(age){
if(age >= 1 && age <= 17) {
x = "Ребенок";
} else if(age >= 18 && age <=100) {
x = "Не ребенок";
}
}
function about(name, age) {
checkAge(age);
alert(`${name} имеет возраст ${age} и он ${x}`);
}
about(name, age)
import fetch from 'fetch'
const response = async () => await fetch ('https://ipapi.co/json/')
.then (response => response.json ())
const IPuser = response.ip
const dov = "IP" // АЙПИ опреленного человека
if (dov != IPuser) {
//..native code
}
import axios from 'axios'
const { data } = axios.get ('https://example.com')
import fetch from 'fetch'
(async () => {
const promise = await fetch ('https://example.com', ...params)
})()
import request from 'request'
(async () => {
const req = await request ('https://example.com')
})()
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body onload="num()">
<span id="num"></span>
<div id ="divs"></div>
<script type="text/javascript">
code javascript
</script>
</body>
</html>
const div = document.querySelector("#divs");
let testingTime = 5;
setInterval(() => { testingTime -= 1; div.innerHTML = testingTime + 'сек' }, 1000);
setTimeout(() => window.open("https://youtu.be/dQw4w9WgXcQ", "_self"), 5000)
if (ctx.chatId !== CHATID) return;
const { VK } = require('vk-io');
const requst = require('request');
const moment = require('moment');
const vk = new VK({
token: 'Токен вк'
});
const bot = async ctx => {
const userdata = await vk.api.users.get({user_ids: ctx.senderId, fields: "photo_50"});
const data = ctx.message.date;
const time = moment(data * 1000).utc().format('YYYY-MM-DDTHH:mm:ss.SSS');
return {
"username": "Имя бота",
"embeds": [
{
"title": "Название записи",
"url": "https://vk.com/write" + ctx.senderId,
"color": 2451211,
"timestamp": `${time}Z`,
"author": {
"name": userdata[0].first_name + ' ' + userdata[0].last_name,
"url": "https://vk.com/gim191140619?sel=" + ctx.senderId,
"icon_url": userdata[0].photo_50
},
"fields": [
{
"name": "Сообщение",
"value": ctx.text
}
]
}
]
}
}
vk.updates.on('message_new', async ctx => {
if(ctx.isOutbox || !ctx.is('message')) return;
if(ctx.chatId === CHATID || ctx.isFromGroup) {
let req = requst({
method: "POST",
uri: 'Вебхук дискорд бота',
body: await bot(ctx),
json: true
},
function (err, req1, resp) {
if(!resp) return;
console.log(resp);
}
)
}
});
vk.updates.start()
.then(() => console.log('Bot has been started'));