TGViewer
Channel Public Channel
ботик

ботик

@botikst

На этом канале публикуются все истории (как и что я делаю в Майнкрафте).
Основной канал: https://t.me/botikdeadpriz
Subscribers
22
Photos
9
Videos
18
Links
2
Recent Posts 20 shown
Post #115 12
пример WebSocket10
Post #112 12
Скрипт WebSocket10
const TelegramBot = require('node-telegram-bot-api');
const WebSocket = require('ws');
const WebSocketServer = require('ws').WebSocketServer;

const token = 'ВАШ_ТОКЕН_БОТА';
const bot = new TelegramBot(token, { polling: true });

let mcWebSocket = null;
let chatId = null;

const wss = new WebSocketServer({ port: 8000, host: '0.0.0.0' }); //port НужноЗаписатьСвободныйПорт_ИспользуйтеОт_2000_До_9000_порт8000МожетБытьЗанят
console.log('WebSocket');

wss.on('connection', (ws) => {
console.log('player connect');
mcWebSocket = ws;

if (chatId) {
bot.sendMessage(chatId, 'bot connect');
}

ws.on('message', (data) => {
try {
const message = JSON.parse(data);
console.log('message play', JSON.stringify(message, null, 2));

if (message.header && message.header.event === 'chat') {
const playerName = message.body.sender || 'Player';
const text = message.body.message || 'Message';
if (chatId) {
bot.sendMessage(chatId, `${playerName}: ${text}`);
}
}
} catch (error) {
console.log('error', error);
}
});

ws.on('close', () => {
console.log('disabled player');
mcWebSocket = null;
if (chatId) {
bot.sendMessage(chatId, 'disabled bot');
}
});

ws.on('error', (error) => {
console.log('error WebSocket ', error.message);
});
});

bot.onText(/\/start/, (msg) => {
chatId = msg.chat.id;
bot.sendMessage(chatId, 'bot launched');
bot.sendMessage(chatId, 'connect localhost:');
});

bot.on('message', (msg) => {
if (msg.text && msg.text.startsWith('/')) return;

chatId = msg.chat.id;
if (mcWebSocket && mcWebSocket.readyState === WebSocket.OPEN) {
const command = `tellraw @a {"rawtext":[{"text":"§b<Telegram> §f${msg.text}"}]}`;

const message = {
header: {
requestId: Math.random().toString(36).substring(2, 10),
messagePurpose: "commandRequest",
version: 1
},
body: {
commandLine: command,
origin: {
type: "player"
}
}
};

mcWebSocket.send(JSON.stringify(message));
console.log(`play: ${msg.text}`);
} else {
bot.sendMessage(chatId, 'bot not connected');
}
});

console.log('bot connect > message');
Post #110 15
Команды termux:
termux-setup-storage

pkg update && pkg upgrade -y

pkg install nodejs-lts nano -y

mkdir mc-telegram-bot

cd mc-telegram-bot

nano bot.js

npm init -y

npm install node-telegram-bot-api@0.64.0

npm install ws

node bot.js

minecraft
/connect localhost:8000

localhost автоматически адресуется на ваш айпи адрес
8000 - выбирайте любое другое число для порта, так как возможно данный порт могут занять на некоторое время. (команда termux проверка занятости порта: netstat -tulpn \| grep 8000)

Узнать свой айпи в termux - ifconfig
Post #109 33
Пример «Импульс»
Post #106 25
Скрипт сущность «Импульс»

import { world, system } from "@minecraft/server";

const speed = 0.25;
const grav = 0.08;

system.runInterval(() => {
const dimension = world.getDimension("overworld");
const entities = dimension.getEntities({ tags: ["my_mob"] });

for (const entity of entities) {
const vel = entity.getVelocity();
let impulseX = 0;
let impulseY = 0;
let impulseZ = 0;

if (entity.hasTag("x")) {
impulseX = speed - vel.x;
}

if (entity.hasTag("y")) {
impulseY = speed - vel.y + grav;
}

if (entity.hasTag("z")) {
impulseZ = speed - vel.z;
}

if (impulseX !== 0 || impulseY !== 0 || impulseZ !== 0) {
entity.applyImpulse({
x: impulseX,
y: impulseY,
z: impulseZ
});
}
}
});
Post #105 22
Скрипт игрок «Импульс»

import { world, system } from "@minecraft/server";

const speed = 0.25;
const grav = 0.08;

system.runInterval(() => {
for (const player of world.getPlayers()) {
const vel = player.getVelocity();
let impulseX = 0;
let impulseY = 0;
let impulseZ = 0;

if (player.hasTag("x")) {
impulseX = speed - vel.x;
}

if (player.hasTag("y")) {
impulseY = speed - vel.y + grav;
}

if (player.hasTag("z")) {
impulseZ = speed - vel.z;
}

if (impulseX !== 0 || impulseY !== 0 || impulseZ !== 0) {
player.applyImpulse({
x: impulseX,
y: impulseY,
z: impulseZ
});
}
}
});
Post #104 38
пример script 1.1.0
entity.DynamicProperty
Post #102 31
script 1.1.0 шаблон скрипт entity.DynamicProperty
import { world, system } from '@minecraft/server';

const stgpref = 'data_server';
const maxm = 5;
const chksz = 32000;
const appsz = 10000;

function getm() {
const m = [];
for (let i = 1; i <= maxm; i++) {
const t = stgpref + i;
const e = world.getDimension('overworld').getEntities({
type: 'minecraft:armor_stand',
tags: [t]
});
if (e.length > 0) {
m.push({ mob: e[0], idx: i });
} else {
m.push(null);
}
}
return m;
}

function svd(d) {
const m = getm();
const c = [];
for (let i = 0; i < d.length; i += chksz) {
c.push(d.substring(i, i + chksz));
}
if (c.length > maxm) {
return false;
}
for (let i = 0; i < c.length; i++) {
const mi = m[i];
if (!mi) {
return false;
}
mi.mob.setDynamicProperty('data', c[i]);
}
for (let i = c.length; i < maxm; i++) {
if (m[i]) {
m[i].mob.setDynamicProperty('data', undefined);
}
}
return true;
}

function ldd() {
const m = getm();
const p = [];
for (const mi of m) {
if (!mi) continue;
const d = mi.mob.getDynamicProperty('data');
if (d !== undefined && d !== null && d !== '') {
p.push(d);
}
}
return p.length > 0 ? p.join('') : null;
}

function gtsz() {
let t = 0;
const m = getm();
for (const mi of m) {
if (!mi) continue;
const d = mi.mob.getDynamicProperty('data');
if (d) t += d.length;
}
return t;
}

function shinf() {
const m = getm();
let msg = 'DAT ser\n';
let t = 0;
for (const mi of m) {
if (!mi) {
msg += `${stgpref}?\n`;
continue;
}
const d = mi.mob.getDynamicProperty('data');
const u = d ? d.length : 0;
msg += `${stgpref}${mi.idx}: ${u}/${chksz} byte (${(u / 1024).toFixed(1)} KB)\n`;
t += u;
}
msg += `tot: ${t} byte, ${(t / 1024).toFixed(1)} KB`;
world.sendMessage(msg);
}

function rndstr(l) {
const c = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let r = '';
for (let i = 0; i < l; i++) {
r += c.charAt(Math.floor(Math.random() * c.length));
}
return r;
}

function appnd() {
const m = getm();
for (const mi of m) {
if (!mi) {
world.sendMessage('Создать всех data_server');
return;
}
}

let ed = ldd();
let o;
if (ed) {
try {
o = JSON.parse(ed);
} catch (e) {
world.sendMessage('error data');
o = {};
}
} else {
o = {};
}

let fi = 0;
while (o.hasOwnProperty('field' + fi)) {
fi++;
}

o['field' + fi] = rndstr(appsz);

const js = JSON.stringify(o);
const ms = maxm * chksz;

if (js.length > ms) {
world.sendMessage(`result (${js.length} byte) limit (${ms} byte)`);
return;
}

if (svd(js)) {
world.sendMessage(`data: +${appsz} failed${fi}. tot: ${js.length} byte (${(js.length/1024).toFixed(1)} KB).`);
} else {
world.sendMessage('failed data');
}
}

function deld() {
const m = getm();
for (const mi of m) {
if (!mi) continue;
mi.mob.setDynamicProperty('data', undefined);
}
world.sendMessage('delete');
}

function prc() {
const m = getm();
for (const mi of m) {
if (!mi) continue;
const mob = mi.mob;
const t = mob.getTags();

if (t.includes('dynamic')) {
shinf();
mob.removeTag('dynamic');
}
if (t.includes('over')) {
appnd();
mob.removeTag('over');
}
if (t.includes('delete_data')) {
deld();
mob.removeTag('delete_data');
}
}
}

system.runInterval(() => {
prc();
}, 10);
Post #98 63
Пример команд (chatSend)
  • 👍 2
  • 🔥 1
Post #96 60
Скрипт команды (chatSend)
import { world, system } from "@minecraft/server";

world.beforeEvents.chatSend.subscribe((data) => {
fik(data)
})

function fik(data) {
const send = data.sender;
const message = data.message;
const cach1 = message === "!start";
const cach2 = message === "!help";
const cach3 = message === "!menu";
const cach4 = message === "!admin";
const ff = message === "!";

const cancel = (cach1 || cach2 || cach3 || cach4 || ff) && (data.cancel = true);
const che1 = cach1 && system.run(() => {
send.runCommand(`title @a title команда start`);
});
const che2 = cach2 && system.run(() => {
send.runCommand(`title @a title команда help`);
});
const che3 = cach3 && system.run(() => {
send.runCommand(`title @a title команда menu`);
});
const che4 = cach4 && system.run(() => {
if (send.hasTag("op")) {
send.runCommand(`title @a title команда admin`);
} else {
send.runCommand(`title @a title нет тега "op"`);
}
});
const ffi = ff && system.run(() => {
send.sendMessage(`!start\n!help\n!menu\n!admin (tag=op)`);
});

return;
}
Older posts →

About this channel

How can I read @botikst without a Telegram account?
TGViewer shows the public web preview Telegram publishes for ботик: recent posts, photos, videos and the subscriber count, with no app, login or account.
How many subscribers does ботик have?
ботик (@botikst) has 22 subscribers on Telegram, refreshed roughly every 30 minutes.
Does ботик know I viewed it here?
No. Public channel previews carry no viewer identity, and TGViewer has no accounts or tracking of what you look up.
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →