const targetNavbar = document.querySelector('.targetNavbar');
const fixedNavbar = document.querySelector('.fixedNavbar');
const obFixedNavbar = new IntersectionObserver(obCallback);
function obCallback(payload) {
if (payload[0].boundingClientRect.y < 0) {
document.querySelector('.class1').style.marginBottom
= fixedNavbar.offsetHeight + 'px';
fixedNavbar.classList.add('class2');
} else {
fixedNavbar.classList.remove('class2');
document.querySelector('.class1').style.marginBottom = '0';
}
}
obFixedNavbar.observe(targetNavbar);
window.addEventListener('resize', () => {
obFixedNavbar.disconnect()
;
obFixedNavbar.observe(targetNavbar);
});
=> {
dispatch(setCanvas(canvasRef.current));
dispatch(setTool(new Brush(canvas)));
console.log('canvas from board', canvas);
console.log('tool', tool);
}, [dispatch]);
=> {
dispatch(setCanvas(canvasRef.current));
}, [dispatch, canvasRef.current]);
useEffect(() => {
dispatch(setTool(new Brush(canvas)));
}, [dispatch, canvas]);
canvas = useSelector((state) => state.canvas.canvas || {});
const tool = useSelector((state) => state.tool || {});
import React, { useRef, useEffect } from 'react';
import './Board.scss';
import { useSelector, useDispatch } from 'react-redux';
import { setCanvas } from '../../store/canvasSlice';
import { setTool } from '../../store/toolSlice';
import Brush from '../../tools/Brush';
export const Board = () => {
const canvasRef = useRef();
const canvas = useSelector((state) => state.canvas.canvas);
const tool = useSelector((state) => state.tool);
const dispatch = useDispatch();
useEffect(() => {
dispatch(setCanvas(canvasRef.current));
dispatch(setTool(new Brush(canvas)));
}, [canvas, dispatch, tool]);
return <canvas ref={canvasRef} className='board' width={1920} height={1080}></canvas>;
};
var j = 1;
var id = setInterval(remove, 100);
function remove() {
$('.i-am-os[data-id="' + j + '"]').animate({
opacity: '0',
color: '#00000000'
}, 100, function () {
$(this).remove()
});
j++;
if (j > 22) {
clearInterval(id);
}
}
with open("/var/www/html/file.txt", "a") as f:
f.write("123")
from vkbottle import GroupEventType, Message
from vkbottle.bot import Bot
# replace GROUP_CHAT_ID with the ID of your group chat
GROUP_CHAT_ID = 123456789
bot = Bot("TOKEN")
@bot.on.message_handler(GroupEventType.WALL_POST_NEW)
async def wall_post_new(message: Message):
try:
await bot.api.messages.send(
peer_id=-GROUP_CHAT_ID, # use negative group chat ID to indicate a group chat
message="Новый пост!",
random_id=0,
attachment=f"wall-{message.group_id}_{message.object.id}"
)
except Exception as ex:
print(f"error: {ex}")
from vkbottle import GroupEventType, Message
from vkbottle.bot import Bot
@bot.on.message_handler(GroupEventType.WALL_POST_NEW)
async def wall_post_new(message: Message):
conversations = await bot.api.messages.get_conversations(peer_types=["chat"])
for conv in conversations:
peer_id = conv.peer.id # access the 'id' attribute of the 'peer' object
try:
await bot.api.messages.send(
peer_id=peer_id,
message='Новый пост!',
random_id=0,
attachment=f'wall-{message.group_id}_{message.object.id}'
)
except Exception as ex:
print(f'error: {ex}')
from vkbottle import GroupEventType, Message
@bot.on.message_handler(GroupEventType.WALL_POST_NEW)
async def wall_post_new(message: Message):
conversations = await bot.api.messages.get_conversations(peer_types=["chat"])
for conv in conversations.items:
peer_id = conv.peer.id # access the 'id' attribute of the 'peer' object
try:
await bot.api.messages.send(
peer_id=peer_id,
message='Новый пост!',
random_id=0,
attachment=f'wall-{event.group_id}_{event.object.id}'
)
except Exception as ex:
print(f'error: {ex}')
from vkbottle import GroupEventType, Message
@bot.on.message_handler(GroupEventType.WALL_POST_NEW)
async def wall_post_new(message: Message):
conversations = await bot.api.messages.get_conversations(peer_types=["chat"])
for conv in conversations.items:
peer_id = conv.peer_id
try:
await bot.api.messages.send(
peer_id=peer_id,
message='Новый пост!',
random_id=0,
attachment=f'wall-{event.group_id}_{event.object.id}'
)
except Exception as ex:
print(f'error: {ex}')
from vkbottle import GroupEventType, Message
@bot.on.message_handler(GroupEventType.WALL_POST_NEW)
async def wall_post_new(message: Message):
conversations = await bot.api.messages.get_conversations(peer_types=["chat"])
for conv in conversations.items:
peer_id = conv.peer.id
try:
await bot.api.messages.send(
peer_id=peer_id,
message='Новый пост!',
random_id=0,
attachment=f'wall-{event.group_id}_{event.object.id}'
)
except Exception as ex:
print(f'error: {ex}')
conversations_response = await bot.api.messages.getConversations(filter='all')
conversations = conversations_response.items
for conversation in conversations:
peer_id = conversation.peer.id
try:
await bot.api.messages.send(
peer_id=peer_id,
message='Новый пост!',
random_id=0,
attachment=f'wall-{event.group_id}_{event.object.id}'
)
except Exception as ex:
print(f'error: {ex}')
import vk_api
# авторизация бота
vk_session = vk_api.VkApi(token='токен_бота')
vk = vk_session.get_api()
# получение списка всех бесед бота
conversations = vk.messages.getConversations(peer_type='chat')['items']
# отправка сообщения в каждую беседу
for conv in conversations:
peer_id = conv['peer']['id']
try:
vk.messages.send(peer_id=peer_id, message='Новый пост!', random_id=0, attachment=f'wall-{event.group_id}_{event.object.id}')
except Exception as ex:
print(f'error: {ex}')