Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions KriptonGerritBot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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() # touch sentcommits/id

time.sleep(10)
Empty file added sentcommits/__init_dir__
Empty file.