Created
December 15, 2015 12:16
-
-
Save ozcan/b32ba4259e4e785e6422 to your computer and use it in GitHub Desktop.
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 json | |
| import urllib2 | |
| import os | |
| import time | |
| import telegram | |
| kripton_people = ['kadertarlan', 'yeliztaneroglu', 'ozcanesen', 'aybuke', 'gulsahkose'] | |
| bot = telegram.Bot(token='TOKEN') | |
| while True: | |
| data = urllib2.urlopen('http://gerrit.libreoffice.org/changes/?n=25&O=81') | |
| json_text = data.read() | |
| json_text = json_text[5:] # trim | |
| latest_changes = json.loads(json_text) | |
| for patch in latest_changes: | |
| _number = str(patch['_number']) | |
| if patch['owner']['username'] in kripton_people and not os.path.exists("sentcommits/" + _number): | |
| message = 'Gonderen: ' + patch['owner']['username'] + \ | |
| '\n - Durum: ' + patch['status'] + \ | |
| '\n - Baslik: ' + patch['subject'] + \ | |
| '\n - Degisiklik: +' + str(patch['insertions']) + ' -' + str(patch['deletions']) + \ | |
| '\n - Baglanti: https://gerrit.libreoffice.org/#/c/' + _number | |
| subscribers = [] | |
| for update in bot.getUpdates(): | |
| chat_id = update['message']['chat']['id'] | |
| if chat_id not in subscribers: | |
| subscribers.append(chat_id) | |
| for chat_id in subscribers: | |
| try: | |
| bot.sendMessage(chat_id, message) | |
| except: | |
| pass | |
| open("sentcommits/" + _number, 'a').close() | |
| time.sleep(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment