await context.loadMessagePayload({ force: true });
attachment.toString()
на выходе будет формат ВКонтакте.cmd.on(/^(?:test)$/i, async (message, bot) => {
let senderId;
// Если ответ на сообщение
if (message.hasReplyMessage) {
senderId = message.replyMessage.senderId;
// Если пересланное сообщение
} else if (message.hasForwards) {
senderId = message.forwards[0].senderId;
}
console.log('senderId', senderId)
})
package test;
import java.io.FileWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class MAin {
public static void main(String[] args) {
String key = "7075966f7075966f7075966f577018909e770757075966f2dfd2579655817dfd28d3bfd";
String Vers = "5.103";
String url = "https://api.vk.com/method/photos.search?user_ids=210700286&fields=bdate&lat=55.879960&long=38.227373&count=1"
+ "&access_token=" + key+"&v="+Vers;
try {
URL obj = new URL(url);
HttpURLConnection connection = (HttpURLConnection) obj.openConnection();
connection.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
// System.out.println(response.toString());
try (FileWriter file = new FileWriter("./response-vk.json")) {
file.write(response.toString());
}
}catch(Exception e){}
}
}
const GROUP_ID = 123456789;
const mentionPattern = new RegExp(
String.raw`^(?:\[club${GROUP_ID}\|[^\]]+\])(?:[\s.,\'\"!?\-+]+|$)`,
'i'
);
vk.updates.on('message', (context, next) => {
if (context.isChat && !mentionPattern.test(context.text)) {
return;
}
if (context.text) {
context.text = context.text.replace(mentionPattern, '');
}
return next();
});
let icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAnUlEQVR42u3bMQ7AIAgAQP//afuE1hSw1CNhccFcIoPimHOOk3MAAADgLrNiVx0AAAC8A8hqSFF1AFQBZB+B1ToAAADYC5DVBKPWAVQBZB8BAAAA9AI4vgkCeLgxAAAAAAAAAAAAAAAAAAAAAAAAAAAAuBQF4GEEAAAA3QBMiJwKsBoAAADoDVA1LA3gawBRAQAAgB4Afo4CAPDfvABS2dwbcpzXlAAAAABJRU5ErkJggg==';
const iconBuffer = Buffer.from(icon.replace('data:image/png;base64,', ''), 'base64');
context.sendPhoto(iconBuffer, {message: `test`});