Skip to content

Instantly share code, notes, and snippets.

@dniHze
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dniHze/a64aa5fd1212cc864294 to your computer and use it in GitHub Desktop.
Save dniHze/a64aa5fd1212cc864294 to your computer and use it in GitHub Desktop.
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