コード例 #1
0
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
コード例 #2
0
    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
        response = self.autorespond(body)
        return Message(to_jid=stanza.get_from(),
                       from_jid=stanza.get_to(),
                       stanza_type=stanza.get_type(),
                       subject=stanza.get_subject(),
                       body=response)


#end class

if len(sys.argv) != 2:
    print notify('!', 'r', "Usage: %s <nick_to_clone>" % sys.argv[0])
    sys.exit(1)
nick = sys.argv[1]

if ROOM_TYPE == 'MUC':
    jidname = nick + '@' + DOMAIN
else:
    sys.exit(notify('!', 'r', "%s is not supported yet" % ROOM_TYPE))
jidname = getuser() + '@' + DOMAIN

mucroombot.setup_localization()
while mucroombot.main(lambda: CloneClient(JID(jidname), getpass(), nick)):
    pass
    # vi: sts=4 et sw=4
コード例 #3
0
    if not m: return
    to_eval = m.group(1).encode('ascii', 'ignore')
    try:
        if lang == 'python':
            return str(eval(to_eval))
        elif lang == 'perl':
            to_eval = to_eval.replace('/', '\/').replace('`', '')
            return runpipe('perl', 'print (%s),"\\n"' % to_eval)
        elif lang == 'ruby':
            to_eval = to_eval.replace('/', '\/').replace('`', '')
            return runpipe('ruby', 'puts (%s)' % to_eval)
        elif lang == 'haskell':
            return runpipe('ghci -v0', to_eval)

        return "%s(%s)" % (lang, to_eval)
    except Exception, e:
        return str(e)


mucroombot.setup_localization()
if ROOM_TYPE == 'MUC':
    jidname = getuser() + '@' + DOMAIN
    mk_client = lambda: MucEvalClient(JID(jidname), getpass(), BOT_NAME)
    while mucroombot.main(mk_client):
        pass
elif ROOM_TYPE == 'IRC':
    mk_client = lambda: IrcEvalClient(BOT_NAME)
    while ircbot.main(mk_client):
        pass
# vi: sts=4 et sw=4
コード例 #4
0
def main_muc(opts):
    jid = JID(opts.username + '@' + DOMAIN)
    mkbot = lambda: MucClient(jid, getpass(), opts.nick, opts.log)
    while mucroombot.main(mkbot):
        pass
コード例 #5
0
ファイル: bot.py プロジェクト: iferguson90/Walrus
def main_muc(opts):
    jid = JID(opts.username+'@'+DOMAIN)
    mkbot = lambda: MucClient(jid, getpass(), opts.nick, opts.log)
    while mucroombot.main(mkbot): pass
コード例 #6
0
ファイル: evalbot.py プロジェクト: iferguson90/Walrus
def evalmsg(msg):
    m = re.match("%s(?:_bot)?[>:\-,]\s+(.+)"%lang,msg)
    if not m: return
    to_eval = m.group(1).encode('ascii','ignore')
    try:
        if lang == 'python':
            return str(eval(to_eval))
        elif lang == 'perl':
            to_eval = to_eval.replace('/','\/').replace('`','')
            return runpipe('perl','print (%s),"\\n"'%to_eval)
        elif lang == 'ruby':
            to_eval = to_eval.replace('/','\/').replace('`','')
            return runpipe('ruby','puts (%s)'%to_eval)
        elif lang == 'haskell':
            return runpipe('ghci -v0',to_eval)
            
        return "%s(%s)"%(lang,to_eval)
    except Exception, e:
        return str(e)

mucroombot.setup_localization()
if ROOM_TYPE == 'MUC':
    jidname = getuser()+'@'+DOMAIN
    mk_client = lambda: MucEvalClient(JID(jidname),getpass(),BOT_NAME)
    while mucroombot.main(mk_client): pass
elif ROOM_TYPE == 'IRC':
    mk_client = lambda: IrcEvalClient(BOT_NAME)
    while ircbot.main(mk_client): pass
# vi: sts=4 et sw=4

コード例 #7
0
        if stanza.get_type() == "headline":
            return True
        print colorize("g", frm + ":"), body
        response = self.autorespond(body)
        return Message(
            to_jid=stanza.get_from(),
            from_jid=stanza.get_to(),
            stanza_type=stanza.get_type(),
            subject=stanza.get_subject(),
            body=response,
        )


# end class

if len(sys.argv) != 2:
    print notify("!", "r", "Usage: %s <nick_to_clone>" % sys.argv[0])
    sys.exit(1)
nick = sys.argv[1]

if ROOM_TYPE == "MUC":
    jidname = nick + "@" + DOMAIN
else:
    sys.exit(notify("!", "r", "%s is not supported yet" % ROOM_TYPE))
jidname = getuser() + "@" + DOMAIN

mucroombot.setup_localization()
while mucroombot.main(lambda: CloneClient(JID(jidname), getpass(), nick)):
    pass
# vi: sts=4 et sw=4