Skip to content
Ethosa edited this page Feb 19, 2022 · 10 revisions

The main module in Shizuka.

Authorization

User

Via Login and password:

var vk = newVk(89123456789, "your password")

Via access_token:

var vk = newVk(access_token="your access token here")

Group

var vk = newVk("your access token here", 123456789)

Calling methods

Without macro

var response = await vk.callVkMethod("users.get", %*{"user_ids": "akihayase"})

With ~ macro

var response = await vk~users.get(user_ids="akihayase")

Receiving real-time events

Without macro

var
  vk = newVk(...)
  lp = vk.newLongpoll()

for event in lp.listen():
  if event["type"].getStr == "message_new":
    echo event

With @ macro

var
  vk = newVk(...)
  lp = vk.newLongpoll()

vk@message_new(event):
  echo event

lp.run()

Closes events handler:

lp.close()
Clone this wiki locally