def main():
    if len(argv) < 3:
        print notify('!','r',"Usage: %s <name> <shakespeare_play(s)>"%argv[0])
        print notify('i','y',"<name> - character name, 'will' for all chars")
        print notify('i','y',"<play(s)> - 1+ plays (on shakespeare.mit.edu)")
        exit(1)
    if not DOMAIN or ROOM_TYPE != 'MUC':
        print notify('!','r',"Error: Only MUC rooms are supported")
        exit(2)
    # use 'will' to grab all characters
    nick = argv[1]
    pages = (urlopen('http://shakespeare.mit.edu/%s/full.html'%play.lower()) \
                for play in argv[2:])
    jidname = getuser()+'@'+DOMAIN
    mucroombot.setup_localization()
    mk_bot = lambda: ShakespeareClient(JID(jidname),getpass(),pages,nick)
    while mucroombot.main(mk_bot): pass
Exemple #2
0
                self.msg_idx -= 1
        else:
            self.history[self.msg_idx] += c

    def session_started(self):
        self._session_started_helper(MucClient(),JID(ROOM,SERVER))

    def message(self,stanza):
        body=stanza.get_body()
        frm = stanza.get_from().as_utf8().split('@')[0]
        if stanza.get_type()=="headline": return True
        print colorize('g',frm+':'),body
        return True
#end class

mucroombot.setup_localization()

# set terminal to character mode
old_settings = termios.tcgetattr(sys.stdin)
#tty.setcbreak(sys.stdin.fileno())

def loop(c):
    while True:
        stream = c.get_stream()
        if not stream: break
        act = stream.loop_iter(0.5)
        if not act: 
            rr,_,_ = select([sys.stdin],[],[],0)
            if len(rr) == 0:
                c.idle()
            else:
Exemple #3
0
            self.history[self.msg_idx] += c

    def session_started(self):
        self._session_started_helper(MucClient(), JID(ROOM, SERVER))

    def message(self, stanza):
        body = stanza.get_body()
        frm = stanza.get_from().as_utf8().split('@')[0]
        if stanza.get_type() == "headline": return True
        print colorize('g', frm + ':'), body
        return True


#end class

mucroombot.setup_localization()

# set terminal to character mode
old_settings = termios.tcgetattr(sys.stdin)
#tty.setcbreak(sys.stdin.fileno())


def loop(c):
    while True:
        stream = c.get_stream()
        if not stream: break
        act = stream.loop_iter(0.5)
        if not act:
            rr, _, _ = select([sys.stdin], [], [], 0)
            if len(rr) == 0:
                c.idle()