Dave Cridland Application 2012

When voting reopens, please run the following to assist in your voting.


 * 1) !/usr/bin/env python
 * 2) -*- coding: utf-8 -*-

import sys import sleekxmpp import logging
 * 1) Use a modern Sleek - then you're using my SASL implementation.
 * 2) (Massively improved by Lance Stout).

if sys.version_info < (3, 0): reload(sys) sys.setdefaultencoding('utf8') else: raw_input = input
 * 1) Python versions before 3.0 do not use UTF-8 encoding
 * 2) by default. To ensure that Unicode is handled properly
 * 3) throughout SleekXMPP, we will set the default encoding
 * 4) ourselves to UTF-8.

MEMBERBOT = 'memberbot@jabber.org'

class VotingAid(sleekxmpp.ClientXMPP): def __init__(self, jid, password): sleekxmpp.ClientXMPP.__init__(self, jid, password) self.add_event_handler("session_start", self.start) self.add_event_handler("message", self.message)

def message(self, msg): if msg['from'].bare == MEMBERBOT: if 'Dave Cridland' in msg['body']: # I'd mention here about my work on the XSF Board, my previous work on the Council, # the work on IETF directorates, the RFCs, the XEPs. # I could talk about working for Isode, directly on XMPP servers used by government and military. # But let me make this simpler for you: self.sendMessage(msg['from'], 'yes', mtype='chat') elif 'type ok to begin' in msg['body']: # This one says yes or no. But expects ok... self.sendMessage(msg['from'], 'ok', mtype='chat') elif 'Would you like to vote on the current topic' in msg['body']: # Special case this so we don't need to ask the user. self.sendMessage(msg['from'], 'yes', mtype='chat') elif 'yes or no' in msg['body']: print msg['body'] self.sendMessage(msg['from'], raw_input('Yes or no? '), mtype='chat') else: import sys sys.exit # Rough, but we're done.

def start(self, evt): self.get_roster self.send_presence(ppriority=-1, pstatus='VotingAid') self.sendMessage(MEMBERBOT, "Hello!", mtype='chat')

def main: import getpass # Setup logging. logging.basicConfig(level=logging.DEBUG,                       format='%(levelname)-8s %(message)s') tmp = VotingAid(raw_input('Jid: '), getpass.getpass('Password: ')) tmp.connect while True: tmp.process(block=True)

if __name__ == '__main__': main