def start(self):
global img_source, img_source2, split_url, split_url2
loop_counter = 0
for event in self.long_poll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
loop_counter += 1
username = self.get_user_name(event.object.from_id)
if event.object.attachments:
if len(event.object.attachments) == 1:
img_source = event.object.attachments[0].get('photo').get('sizes')[2].get('url')
split_url = img_source
split_url = split_url.split("/")[-1:][0].split(".")[0]
elif len(event.object.attachments) == 2:
img_source2 = event.object.attachments[1].get('photo').get('sizes')[2].get('url')
split_url2 = img_source2
split_url2 = split_url2.split("/")[-1:][0].split(".")[0]
if event.object.text:
if event.object.text.lower() == 'начать':
..................
elif event.object.text == 'Описание доступных функций':
..................
elif event.object.text == 'Применить фильтры':
..................
elif event.object.text == 'Изменить яркость':
..................
elif event.object.text == 'Негатив':
self.send_images(event.object.from_id, ImageFilters.negative(img_source, split_url))
elif event.object.text == 'Горизонтальная склейка':
self.send_images(event.object.from_id, ImageProcessing.cut_and_glue(img_source, img_source2, split_url))
Функция self.send_images(event.object.from_id, ImageFilters.negative(img_source, split_url)), функция self.send_images(event.object.from_id, ImageProcessing.cut_and_glue(img_source, img_source2, split_url)) вызывает ошибку:
Traceback (most recent call last):
File "D:\Develop\vk_image_bot\main.py", line 133, in start
self.send_images(event.object.from_id, ImageProcessing.cut_and_glue(img_source, img_source2, split_url))
NameError: name 'img_source' is not defined