Skip to main content

https://github.com/Fsoky/vktools

Project description

vktools

Tools for vk_api for comfort work

example imports

example keyboard

example code of keyboard

example carousel

example code of carousel

Example code

import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType


from vktools import Keyboard, KeyboardButton, Carousel, CarouselButton

vk = vk_api.VkApi(token="token")


def send_message(user_id, message, keyboard=None, carousel=None):
	values = {
		"user_id": user_id,
		"message": message,
		"random_id": 0
	}

	if keyboard is not None:
		values["keyboard"] = keyboard.add_keyboard()
	if carousel is not None:
		values["template"] = carousel.add_carousel()

	vk.method("messages.send", values)

for event in VkLongPoll(vk).listen():
	if event.type == VkEventType.MESSAGE_NEW and event.to_me:
		text = event.text.lower()
		user_id = event.user_id

		if text == "test":
			keyboard = Keyboard(
				[
					[
						KeyboardButton().text("RED", "negative"),
						KeyboardButton().text("GREEN", "positive"),
						KeyboardButton().text("BLUE", "primary"),
						KeyboardButton().text("WHITE")
					],
					[
						KeyboardButton().openlink("YouTube", "https://youtube.com/c/Фсоки")
					],
					[
						KeyboardButton().location()
					]
				]
			)

			send_message(user_id, "VkTools Keyboard by Fsoky ~", keyboard)
		elif text == "test carousel":
			carousel = Carousel(
				[
					CarouselButton().openlink(
						[
							CarouselButton().element(
								title="Title 1",
								description="Description 1",
								photo_id="-203980592_457239030",
								link="https://vk.com/fsoky",
								buttons=[KeyboardButton().text("Button 1", "positive")]
							),
							CarouselButton().element(
								title="Title 2",
								description="Description 2",
								photo_id="-203980592_457239029",
								link="https://vk.com/fsoky",
								buttons=[KeyboardButton().text("Button 2", "negative")]
							)
						]
					)
				]
			)

			send_message(user_id, "VkTools Carousel by Fsoky ~", carousel=carousel)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vktools-1.0.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vktools-1.0.1-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file vktools-1.0.1.tar.gz.

File metadata

  • Download URL: vktools-1.0.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.7 Windows/10

File hashes

Hashes for vktools-1.0.1.tar.gz
Algorithm Hash digest
SHA256 880ee49bd388b2d413fcd22316e714c5c6188a93c4fdf923fd4ab2d22da3e50b
MD5 1ff6d78fdec2edfa49fa816d42da34c4
BLAKE2b-256 ea78cde1108d0a5779aee4da69ff7a1c89f18ecd5e28d4ca25eefda2db9202ae

See more details on using hashes here.

File details

Details for the file vktools-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: vktools-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.7 Windows/10

File hashes

Hashes for vktools-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a91dd64cf08fe1b97e2edef5c123e97556dd0d26c90d02dfc92be7f7826fdc85
MD5 41d6a596c760da29e9061afa1a22bfa1
BLAKE2b-256 a226f605b333670a396756f7486bb7ad482e7788c7a850fdd42dafab34f5ebfd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page