Last active
August 29, 2015 14:12
-
-
Save dniHze/a64aa5fd1212cc864294 to your computer and use it in GitHub Desktop.
KPI Live Notificator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import vk_api | |
import time | |
from subprocess import call | |
def main(): | |
# your vk login and password | |
login, password = '[email protected]', '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