#!/usr/bin/python from ircbot import SingleServerIRCBot from irclib import nm_to_n import string class ACBot(SingleServerIRCBot): pos=0 def __init__(self,channel,nickname,server,port=6667): SingleServerIRCBot.__init__(self, [(server,port)], nickname, nickname) self.channel = channel self.start() def on_welcome(self, c, e): print "Welcomed, trying to join" c.join( self.channel ) self.connection.notice( self.channel, "I am the arts and culture cue robot") self.connection.notice( self.channel, "to advance an item send the message 'acNext' to the channel") self.connection.notice( self.channel, "to go back an item send the message 'acPrev' to the channel") self.connection.notice( self.channel, "I will not tell you how to terminate me") for i in items[self.pos]: self.connection.notice( self.channel, i ) def on_pubmsg(self, c, e): msg = e.arguments()[0] if msg == "acNext": self.pos += 1 self.printUpdate(e) elif msg == "acPrev": self.pos -= 1 self.printUpdate(e) elif msg == "acKillBot": self.die() def printUpdate(self, e): c = self.connection if self.pos < 0: self.pos = len(items)-1 elif self.pos >= len(items): self.pos = 0 for i in items[self.pos]: c.notice( self.channel, i ) items = [ ["Video" " - laptop audio" " - lights off"], ["Tehzin & Natasha" " - podium microphone" " - podium spotlight"], ["Joinda" " - CD" " - stage lights" " - presentation with cues from music"], ["Afganistan intro (Salima) [sync]" " - stage microphone" " - centre spotlight"], ["Afganistan poetry [sync]" " - CD" " - stage microphone" " - centre spotlight"], ["Afganistan dance" " - stage lights" " - map"], ["Spain intro [sync]" " - stage microphone" " - centre spotlight"], ["Spain slideshow [sync]" " - CD" " - lights off" " - auto-advance"], ["Spain dance" " - CD" " - stage lights" " - map"], ["India intro (Anisa) [sync]" " - centre spotlight" " - stage microphone"], ["India York" " - CD" " - stage lights" " - map"], ["India Waterloo" " - CD" " - stage lights" " - map"], ["Kashmir" " - Intermission"], ["Punjab Pakistan intro (Alys) [sync]" " - stage and instrument microphones [Hafiz handling audio]" " - centre spotlight"], ["Punjab Pakistan Ryerson" " - CD" " - stage lights" " - map"], ["Punjab Pakistan Sitar" " - instrument microphone" " - dim lights" " - map"], ["African intro [sync]" " - stage microphone" " - centre spotlight"], ["African Vasta's monologue" " - stage microphone" " - centre spotlight"], ["African Accapella" " - stage and instrument microphones " " - initial dim lights (barely see)" " - spot (Vasta raises arm)"], ["Western intro rap [all on]" " - stage microphone" " - centre spotlight"], ["Western Farah Merani" " - stage microphone" " - table + chair" " - centre spotlight [if not stationary]" " - stage lights [if spotlight is stationary]" " - map"], ["Western Areez [sync]" " - stage microphone" " - keyboard" " - centre spotlight" " - map"], ["Rizwan Mawani intro" " - podium spotlight" " - podium microphone"], ["Rizwan Mawani slideshow" " - podium microphone" " - podium spotlight" " - manually advance by Rizwan"], ["Rizwan Mawani gift presentation"], ["Grand Finale" " - CD" " - Black Screen: Identity" " - stage lights"], ["Credits" " - CD" " - podium microphone" " - podium spotlight" " - dim lights" " - slideshow"] ] import sys if len(sys.argv) != 4: print "Usage: testbot " sys.exit(1) s = string.split(sys.argv[1], ":", 1) server = s[0] if len(s) == 2: try: port = int(s[1]) except ValueError: print "Error: Erroneous port." sys.exit(1) else: port = 6667 channel = sys.argv[2] nickname = sys.argv[3] bot = ACBot(channel, nickname, server, port) bot.start()