Created
August 8, 2012 14:11
-
-
Save coderofsalvation/3295338 to your computer and use it in GitHub Desktop.
Doorway/bridge between rounduptracker and php IRCBOT 'vikingbot' (or other IPC-supporting process)
This file contains 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
# Copyright (c) 2012 Coder of Salvation | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in | |
# all copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
# SOFTWARE. | |
# | |
#$Id: statusauditor.py,v 1.5 2004-03-27 00:01:48 richard Exp $ | |
# This is a doorway to the IPC-mechanism of the opensource phpIRCbot called 'vikingbot': | |
# https://github.com/Ueland/VikingBot | |
# | |
# What it does: | |
# it notifies creation and modification of tickets to the IRCbot: | |
# (only if it does not contain certain keywords (handy to hide some category of issues) | |
# | |
# Also..here is a script which you can use to let the IRCbot create/modify tickets: | |
# https://github.com/coderofsalvation/VikingBot/blob/master/plugins/issuePlugin.php | |
import os | |
file = '/home/username/vikingbot/db/fileReaderOutput.db' | |
def onset(db, cl, nodeid, values): | |
if values: | |
keyword_ids = values['keyword'] | |
if keyword_ids: | |
if '18' in keyword_ids or '14' in keyword_ids: # dont show issues with 'office' or 'nobilly' keywords | |
return | |
current_status = cl.get(nodeid, 'status') | |
changes = ', '.join( map(str,values) ); | |
user = db.user.get( db.getuid(), 'username' ) | |
title = db.issue.get( nodeid, 'title' ) | |
msg = '[issue' + nodeid + '] "'+ title +'" - was updated by ' + user # + ' (' + changes + ')'; | |
os.system("echo '"+msg+"' > "+file) | |
def oncreate(db, cl, nodeid, values): | |
keyword_ids = db.issue.get( nodeid, 'keyword' ) | |
if keyword_ids: | |
if '18' in keyword_ids or '14' in keyword_ids: # dont show issues with 'office' or 'nobot' keywords | |
return | |
user = db.user.get( db.getuid(), 'username' ) | |
title = db.issue.get( nodeid, 'title' ) | |
msg = '[issue' + nodeid + '] "'+ title +'" - was created by ' + user; | |
os.system("echo '"+msg+"' > "+file) | |
def init(db): | |
# fire before changes are made | |
db.issue.react('set', onset) | |
db.issue.react('create', oncreate ) | |
# vim: set filetype=python ts=4 sw=4 et si | |
#SHA: 97f4de5b9d06b6be7ea73ba639a48141c80deaf9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment