Skip to main content

No project description provided

Project description

VK is library that allows to create chatbots for vk easy and fast

Quickstart

Easiest hi-bot

from VK import Bot


bot = Bot(api_token)

@bot.command('hi')
def greet(message):
    return 'Hi'

bot.start()

Documentation

Bot - main class

Parameters

  • access_token - string to access api
  • bot_admin - id of user, that will gain maximum access for bot`s commands
  • session - GroupSession object to access api (will be created automatically if not passed)
  • event_server - CallBackServer or LongPollServer that will pass events to bot (LongPollServer will bew created automatically)
  • log_file - name of log_file (will bew created at /log directory)
  • log_level

Commands

Bot.command() - decorator for the functions that will be converted to a Command object

Parameters

  • name - the main name of command (by default the name of function)
  • aliases - the alternative names of command
  • access_level - the minimum access level of access to run command
  • message_if_deny - string, that will be replied to message, if access_level less then access_level
  • use_doc - weather or not use the documentation of function in auto-generated documentation

Commands can be declared both synchronous and asynchronous

bot.command()
def hi():
    return 'Hi!'

bot.command()
async def bye():
    return 'Bye-bye!'

You can add message argument to the command-function to gain access to the message, that called the command

bot.command()
def hi(message):
    return f'Hi, {message.sender}!'

Framework will automatically use the returned string as text of message to reply and ignore all other returned objects (including None)

AccessLevel

There are 3 access levels now

  1. USER - every user in conversations
  2. ADMIN - admins of conversation and any user in private chat with bot
  3. BOT_ADMIN - user, that was declared as bot_admin

Regex (Experimental)

You can write functions, that will be automatically called if message matches given pattern

bot.regex('.*hi.*')
async def regex_hi(message):
    await message.reply('Your message contains hi')

Message

Some description

Fields

  • date- time.struct_time - sending time of message
  • text str
  • chat - Chat object, where message was send
  • sender - User object, who send the message

Chat

User

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

vkpybot-0.1.6.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

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

vkpybot-0.1.6-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file vkpybot-0.1.6.tar.gz.

File metadata

  • Download URL: vkpybot-0.1.6.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.1 Windows/10

File hashes

Hashes for vkpybot-0.1.6.tar.gz
Algorithm Hash digest
SHA256 ef67d375e58da5578528c01176ad56aede431a435c582627efaf7411ca593ace
MD5 15cbdc76f4271beb6e9c3eb5a445c18b
BLAKE2b-256 16a4820c04c494415f0c1a96a2046252e593045a22641d81cdad367fc9913f4e

See more details on using hashes here.

File details

Details for the file vkpybot-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: vkpybot-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.1 Windows/10

File hashes

Hashes for vkpybot-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 8d40f3112dbe393bfd498b35e7ce0ef848bdd42410a29927d6a0d13f92933a67
MD5 b0af06af7588cb1215306e25bef81152
BLAKE2b-256 42ef7e207417d5f746747e152572bf309596be3f0dce6a7a67a8ab0327498b86

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