bad_words = ["плохое слово","очень плохое слово"]
@dp.message_handler()
async def filter_messages(message: types.Message):
lower_message = message.text.lower()
for bad_word in bad_words:
if bad_word in lower_message:
await message.delete()
break
vk.api.users.get
f'id{user_info.id} ({user_info.first_name})'
bot.on(['photo'], (ctx) => {
if (ctx.message.photo.length > 1) return;
if (ctx.message.media_group_id) {
const photo = ctx.message.photo[0]
let link = await ctx.telegram.getFileLink(photo.file_id)
const url = link.href
// need send photos to user
ctx.telegram.sendMediaGroup(user_tg_id,[
{
type: 'photo',
media: // url for first photo
},
{
type: 'photo',
media: // url for second photo
},
])
} else {
// works well
const photo = ctx.message.photo[0]
let link = await ctx.telegram.getFileLink(photo.file_id)
const url = link.href
return ctx.telegram.sendPhoto(user_tg_id, {url})
}
})
vk.api.messages.removeChatUser(chat_id=chatId беседы, member_id=ID пользователя)
и в своей базе этого пользователя поставить параметр, отвечающий за бан, на True
while True:
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.object.peer_id != event.object.from_id:
message = event.obj['message']
text = message['text']
if text.lower() == "привет":
vk.method("messages.send", {"peer_id": event.object.peer_id, "message": text,
"random_id": 0})
elif event.object.peer_id == event.object.from_id:
if text.lower() == "привет":
vk.method("messages.send", {"user_id": event.object.from_id, "message": text,
"random_id": 0})
import os
import requests
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor
TOKEN = ''
bot = Bot(token=TOKEN)
dp = Dispatcher(bot)
@dp.message_handler(commands=['start', 'help'])
async def start(message: types.Message):
await bot.send_message(message.chat.id, text='привет')
@dp.message_handler(content_types=['text'])
async def downloader(message: types.Message):
instagram_post = message.text
if "instagram.com" in instagram_post:
changing_url = instagram_post.split("/")
url_code = changing_url[4]
url = f"https://instagram.com/p/{url_code}?__a=1"
global checking_video
try:
visit = requests.get(url).json()
checking_video = visit['graphql']['shortcode_media']['is_video']
except:
await bot.send_message(message.chat.id, text="Send Me Only Public Instagram Posts")
if checking_video==True:
try:
video_url = visit['graphql']['shortcode_media']['video_url']
await bot.send_video(message.chat.id, video=video_url)
except:
pass
elif checking_video==False:
try:
post_url = visit['graphql']['shortcode_media']['display_url']
await bot.send_photo(message.chat.id, photo=post_url)
except:
pass
else:
await bot.send_message(message.chat.id, text="I Cant Send You Private Posts")
else:
await bot.send_message(message.chat.id, text="Kindly Send Me Public Instagram Video/Photo Url")
if __name__ == "__main__":
executor.start_polling(dp, skip_updates=True)