示例#1
0
 def setUp(self):
     self.server = QueueServer("localhost", 0)
     self.server.serve_forever()
     self.hostport = self.server.socket.getsockname()
     self.net_write, self.net_read = network.simple_connect(self.hostport)
     self.server_read = self.server.read_queue
     self.server_write = self.server.write_queue
示例#2
0
文件: main.py 项目: coryk135/Yakr
nick = config.get("bot.nick", False)
name = config.get("bot.name", "Unnamed bot")
if [connect_host, connect_port, nick].count(False):
    print "Minimum requirements for a config file:"
    print "[connection]"
    print "host = SOME_HOST"
    print "port = SOME_PORT"
    print "[bot]"
    print "nick = SOME_NICK"
    exit(1)
connect_port = int(connect_port)

net = None
if len(sys.argv) >= 2:
    if sys.argv[1] == "record":
        conn = simple_connect((connect_host, connect_port))
        net = record(conn, "RECORD")
    if sys.argv[1] == "replay":
        net = replay("RECORD")
    if sys.argv[1] == "test":
        import unittest
        result = unittest.TextTestRunner(verbosity=2).run(unittest.defaultTestLoader.discover('tests'))
        exit_code = 0
        if result.failures:
            exit_code += 1
        if result.errors:
            exit_code += 2
        exit(exit_code)
    if sys.argv[1] == "plugin":
        import yakr.plugin_maker
        yakr.plugin_maker.interactive()
示例#3
0
import yakr.config as botconfig
import sys
set_procname("yakr")

config = botconfig.read("yakr.cfg")

connect_host = config["connection"]["host"]
connect_port = int(config["connection"]["port"])
nick = config["bot"]["nick"]
name = config["bot"]["name"]


net = None
if len(sys.argv) == 2:
    if sys.argv[1] == "record":
        conn = simple_connect((connect_host, connect_port))
        net = record(conn, "RECORD")
    if sys.argv[1] == "replay":
        net = replay("RECORD")
else:
    net = simple_connect((connect_host, connect_port))

b = Bot(net)
b.nick = nick
b.real_name = name
plugins = """alias
alarm
chance
colorize
date
fortune