def handlePubmsg(connection, event): nick=event.source().split('!')[0] msg=event.arguments() msg=msg[0].split(" ") chan=event.target() if (len(msg) > 0 and msg[0].startswith(conf['prefix'])): command=msg[0].split(conf['prefix'])[1] if (len(msg) > 0 and msg[0].startswith(conf['aprefix'])): acommand=msg[0].split(conf['aprefix'])[1] if ('acommand' in locals() and ad.isAdmin(nick)): if (acommand == "cmds"): x = ", ".join(ad.pubAdmin) connection.notice(nick, x) elif (ad.isAdmin(nick) and acommand in ad.pubAdmin): try: package=plug.getPluginPackage(acommand) func=getattr(sys.modules[package],"pubadmin_%s" % acommand) func(connection, msg[1:], chan, nick) except Exception: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback, file=sys.stdout) if ('command' in locals()): if (command == "cmds"): x = ", ".join(coha.pubcmds) connection.notice(nick, x) if (command in plug.loadedPlugins): try: package=plug.getPluginPackage(command) func=getattr(sys.modules[package],"pub_%s" % command) func(connection, msg[1:], chan, nick) except Exception: exc_type, exc_value, exc_traceback = sys.exc_info() logging.exception(traceback.extract_stack())
def adminOrgs(): conn = dbconn2.connect(DSN) if 'CAS_USERNAME' in session: username = session['CAS_USERNAME'] admin = A.isAdmin(conn, username) orgList = G.allOrgs(conn) if admin: act = request.form['submit'] # adding a new org for sofc funding if act == "add": name = request.form['name'] classification = request.form['classification'] sofc = request.form['sofc'] profit = request.form.get('profit', None) A.addOrg(conn, name, classification, sofc, profit) # deleting an org or revoking sofc funding status if act == "delete": name = request.form['name'] A.deleteOrg(conn, name) # updating org info if act == "update": sofc = request.form['name'] return redirect(url_for('displayUpdateOrg', sofc=sofc)) return displayAdminOrgs() else: return redirect(url_for('login'))
def adminUsers(): conn = dbconn2.connect(DSN) if 'CAS_USERNAME' in session: username = session['CAS_USERNAME'] admin = A.isAdmin(conn, username) if admin: act = request.form['submit'] # adding a new treasurer if act == "addTreasurer": orgName = request.form['orgName'] treasurer = request.form['username'] A.addTreasurer(conn, orgName, treasurer) # removing user from being an treasurer if act == "removeTreasurer": orgName = request.form['orgName'] treasurer = request.form['username'] A.deleteTreasurer(conn, orgName, treasurer) # adding user to sofc group if act == "addSOFC": SOFC = request.form['username'] A.addSOFC(conn, SOFC) # removing user from sofc group if act == "removeSOFC": SOFC = request.form['username'] A.deleteSOFC(conn, SOFC) return displayAdminUsers() else: return redirect(url_for('login'))
def adminDeadlines(): conn = dbconn2.connect(DSN) if 'CAS_USERNAME' in session: username = session['CAS_USERNAME'] admin = A.isAdmin(conn, username) if admin: act = request.form['submit'] # allocate funds for deadline if act == "allocateDeadline": deadline = request.form['deadline'] A.calcAllocated(conn, deadline) # creating new deadline if act == "addDeadline": fType = request.form['fType'] deadline = request.form['deadline'] appealsDeadline = request.form['appealsDeadline'] budgetFood = request.form['budgetFood'] budgetNonFood = request.form['budgetNonFood'] A.addDeadline(conn, deadline, fType, budgetFood, budgetNonFood) # deleting deadline if act == "delete": deadline = request.form['deadline'] A.deleteDeadline(conn, deadline) deadlineList = G.allDeadlines(conn) return render_template('adminDeadlines.html', username=username, deadlineList=deadlineList) else: return redirect(url_for('login'))
def handlePrvmsg(connection, event): nick=event.source().split('!')[0] msg=event.arguments() msg=msg[0].split(" ") if (len(msg) > 0 and msg[0].startswith(conf['prefix'])): command=msg[0].split(conf['prefix'])[1] if (len(msg) > 0 and msg[0].startswith(conf['aprefix'])): acommand=msg[0].split(conf['aprefix'])[1] chan=nick if ('acommand' in locals()): if (nick in conf['admins']): if (acommand == "login" and len(msg) > 1 and ad.isAdmin(nick) == False): if (conf['password'] == msg[1]): ad.insertAdmin(nick) connection.privmsg(nick, "Logged in!") else: connection.privmsg(nick, "Incorrect Password!") elif (acommand == "login" and len(msg) > 1 and ad.isAdmin(nick) == True): connection.privmsg(nick,"You are already logged in!") elif (ad.isAdmin(nick) and acommand in ad.builtin and len(msg) > 0): func=getattr(ad,acommand) connection.privmsg(chan,func(msg[1:])) elif (ad.isAdmin(nick) and acommand == "cmds"): x="" if (len(ad.privAdmin) > 0): x = ", " + ", ".join(ad.privAdmin) connection.privmsg(nick, "%s%s" % (", ".join(ad.builtin),x)) elif (ad.isAdmin(nick) and acommand in ad.privAdmin): try: package=plug.getPluginPackage(acommand) func=getattr(sys.modules[package],"privadmin_%s" % acommand) func(connection, msg[1:], chan, nick) except Exception: exc_type, exc_value, exc_traceback = sys.exc_info() logging.exception(traceback.print_exception(exc_type, exc_value, exc_traceback, file=sys.stdout)) if ('command' in locals() and command in plug.loadedPlugins): try: package=plug.getPluginPackage(command) func=getattr(sys.modules[package],"priv_%s" % command) func(connection, msg[1:], chan, nick) except Exception: exc_type, exc_value, exc_traceback = sys.exc_info() logging.exception(traceback.print_exception(exc_type, exc_value, exc_traceback, file=sys.stdout))
def displayAdmin(): conn = dbconn2.connect(DSN) if 'CAS_USERNAME' in session: username = session['CAS_USERNAME'] admin = A.isAdmin(conn, username) if admin: return render_template('admin.html', username=username) else: return redirect(url_for('login'))
def general(): conn = dbconn2.connect(DSN) if 'CAS_USERNAME' in session: username = session['CAS_USERNAME'] treasurer = T.isTreasurer(conn, username) sofc = S.isSOFC(conn, username) admin = A.isAdmin(conn, username) return render_template('general.html') else: return redirect(url_for('login'))
def displayAdminUsers(): conn = dbconn2.connect(DSN) if 'CAS_USERNAME' in session: username = session['CAS_USERNAME'] admin = A.isAdmin(conn, username) sofcOrgList = G.allSOFCOrgs(conn) if admin: return render_template('adminUsers.html', username=username, sofcOrgList=sofcOrgList) else: return redirect(url_for('login'))
def displayAdminDeadlines(): conn = dbconn2.connect(DSN) if 'CAS_USERNAME' in session: username = session['CAS_USERNAME'] admin = A.isAdmin(conn, username) deadlineList = G.allDeadlines(conn) if admin: return render_template('adminDeadlines.html', username=username, deadlineList=deadlineList) else: return redirect(url_for('login'))
def _KICK(context): m = _reKick.match(context.params) if m: chan, me, message = m.groups() if context.getSetting('autorejoin'): context.proc.join(chan) if admin.isAdmin(context): context.proc.action(chan, 'licks %s' % context.sender.nick) else: context.proc.action(chan, 'glares at %s' % context.sender.nick) else: del _currentChannels[chan]
def admin(): conn = dbconn2.connect(DSN) if 'CAS_USERNAME' in session: username = session['CAS_USERNAME'] admin = A.isAdmin(conn, username) if admin: html = request.form['submit'] # possible pages to go to if html == "USERS": return redirect(url_for('adminUsers')) if html == "ORGS": return redirect(url_for('adminOrgs')) if html == "FUNDING DEADLINES": return redirect(url_for('adminDeadlines')) else: return redirect(url_for('login'))
def displayUpdateOrg(sofc): conn = dbconn2.connect(DSN) if 'CAS_USERNAME' in session: username = session['CAS_USERNAME'] admin = A.isAdmin(conn, username) info = G.orgInfo(conn, sofc) if info['canApply'] == 0: canApply = False else: canApply = True if admin: return render_template('adminOrgInfo.html', info=info, canApply=canApply) else: return redirect(url_for('login'))
def updateOrg(sofc): conn = dbconn2.connect(DSN) if 'CAS_USERNAME' in session: username = session['CAS_USERNAME'] admin = A.isAdmin(conn, username) oldName = A.orgName(conn, sofc) if admin: newName = request.form['name'] classification = request.form['classification'] newSOFC = request.form['sofc'] profit = request.form.get('profit', None) canApply = int(request.form['canApply']) A.updateOrg(conn, oldName, newName, classification, sofc, newSOFC, profit, canApply) return displayUpdateOrg(sofc) else: return redirect(url_for('login'))
def home(): conn = dbconn2.connect(DSN) if 'CAS_USERNAME' in session: username = session['CAS_USERNAME'] treasurer = T.isTreasurer(conn, username) sofc = S.isSOFC(conn, username) admin = A.isAdmin(conn, username) else: return redirect(url_for('login')) role = request.form['submit'] if role == "GENERAL MEMBER": return redirect(url_for('general')) if role == "TREASURER": return redirect(url_for('treasurer')) if role == "SOFC MEMBER": return redirect(url_for('sofc')) if role == "ADMIN": return redirect(url_for('admin'))
def displayHome(): conn = dbconn2.connect(DSN) if 'CAS_USERNAME' in session: username = session['CAS_USERNAME'] G.addUser(conn, username) treasurer = T.isTreasurer(conn, username) sofc = S.isSOFC(conn, username) admin = A.isAdmin(conn, username) # redirect automatically to general if not treasurer, sofc, or admin if not (treasurer or sofc or admin): return redirect(url_for('general')) return render_template('home.html', treasurer=treasurer, sofc=sofc, admin=admin) else: return redirect(url_for('login'))
def handleQuit(connection, event): nick=event.source().split('!')[0] if (ad.isAdmin(nick)): ad.removeAdmin(nick)
def handlePart(connection, event): nick=event.source().split('!')[0] if (ad.isAdmin(nick) and event.target() == conf['chan']): ad.removeAdmin(nick)