-
-
Notifications
You must be signed in to change notification settings - Fork 2
Ethosa edited this page Mar 13, 2020
·
10 revisions
The main module in Shizuka.
Via Login and password
:
import shizuka
var vk = Vk("89123456789", "your password", debug=true) # debug param optional.
Via access_token
:
import shizuka
var vk = Vk(access_token="your access token here", debug=true)
import shizuka
var vk = Vk(access_token="your access token here", group_id=123456789, debug=true)
Without macro:
var response = vk.call_method("users.get", %*{"user_ids": "akihayase"})
With ~
macro:
var response = vk~users.get(user_ids="akihayase")
Without macro:
var response = waitFor vk.call_method("users.get", %*{"user_ids": "akihayase"})
With ~
macro:
var response = waitFor vk~users.get(user_ids="akihayase")
for event in vk.longpoll.listen():
if event["type"].getStr == "message_new":
echo event
With eventhandler
macro
var vk = Vk(...)
# This proc will called when got new event with type "message_new".
proc message_new(event: JsonNode) {. eventhandler: vk .} =
echo event
vk.start_listen
With @
macro
var vk = Vk(...)
vk@message_new(event):
echo event
vk.start_listen