Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
KPI Live Notificator
import vk_api
import time
from subprocess import call
def main():
# your vk login and password
login, password = 'yourlogin@vk.com', 'password'
# sometext
sometext = "text"
# path to KPI Live logo
path = "/home/dorosh/live.png"
# auth
try:
vk = vk_api.VkApi(login, password)
except vk_api.AuthorizationError as error_msg:
call(["notify-send" , error_msg])
return
# loop
while True:
#values for response
values = {
'count': 2,
'owner_id': -23762795
}
# response
response = vk.method('wall.get', values)
# checking items is not null
if response['items']:
# cheking for updates
if sometext!=response['items'][1]['text']:
# notification for user
call(["notify-send", "-i", path, "KPI Live", response['items'][1]['text']])
# saving last post
sometext = response['items'][1]['text']
# goto sleep for some time
time.sleep(300)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment