当前位置: 首页>>代码示例>>Python>>正文


Python Bot.start方法代码示例

本文整理汇总了Python中bot.Bot.start方法的典型用法代码示例。如果您正苦于以下问题:Python Bot.start方法的具体用法?Python Bot.start怎么用?Python Bot.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bot.Bot的用法示例。


在下文中一共展示了Bot.start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Spinner

# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import start [as 别名]
class Spinner():
    """
    This is our spinner class, it's what keeps the bot alive.
    It will run until a QuitEvent has been sent out.
    It consumes the event dispatchers queue and then sleeps for 0.01 seconds to reduce overhead.
    """
    def __init__(self, parameters):
        fileName, self.coreFile, self.moduleFile, GUI = parameters;
        self.read_config("all")
        self.ed         = botinfo.bot_info["ed"] = eventdispatcher.EventDispatcher()
        self.alive      = True
        self.bot        = Bot(self.ed)
        self._connection = [
            self.ed.add(QuitEvent, Wbm(self.quit)),
            self.ed.add(ReloadconfigEvent, Wbm(self.read_config))
        ]
        self.bot.start()
        
    
    def tick(self):
        self.ed.consume_event_queue()
        return self.alive
        
    def quit(self, event):
        self.alive = False
        
    def read_config(self, event):
        botinfo.bot_info.update(botinfo.read_config("core", self.coreFile))
        botinfo.bot_info.update(botinfo.read_config("modules", self.moduleFile))
开发者ID:mbriden,项目名称:FatbotIRC,代码行数:31,代码来源:spinner.py

示例2: main

# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import start [as 别名]
def main():
    # Handle configurations
    home_path = os.path.join(os.path.expanduser("~"), ".irk")
    config_path = os.path.join(home_path, "config")

    client_config_file = os.path.join(config_path, "client.conf")
    bot_config_file = os.path.join(config_path, "bot.conf")

    if not os.path.exists(home_path):
        os.mkdir(home_path)

    if not os.path.exists(config_path):
        os.mkdir(config_path)

    if not os.path.exists(client_config_file):
        client_config = config.interactive_build_config(default_client_config)
        config.save_config(client_config_file, client_config)
    else:
        client_config = config.load_config(client_config_file)

    if not os.path.exists(bot_config_file):
        bot_config = config.interactive_build_config(default_bot_config)
        config.save_config(bot_config_file, bot_config)
    else:
        bot_config = config.load_config(bot_config_file)

    # Retroactively patch home_path into configurations.
    client_config['home_path'] = home_path
    bot_config['home_path'] = home_path

    client_proc = Client(client_config)
    bot_proc = Bot(bot_config)
    client_proc.connect_queues(bot_proc)

    client_proc.start()
    bot_proc.start()

    client_proc.join()
    bot_proc.join()
开发者ID:GRAYgoose124,项目名称:irk-new,代码行数:41,代码来源:__main__.py

示例3: Bot

# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import start [as 别名]
import time
from bot import Bot
import settings
import defaults


################
## DEFAULT BOT ## (You can create multiple bots with different settings)
################

bot = Bot(defaults.algorithm, defaults.pair)
bot.start()
print bot._trade
bot.stop()
print bot._trade
开发者ID:FrancescoA,项目名称:BitcoinBot,代码行数:17,代码来源:main.py

示例4: Bot

# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import start [as 别名]
#!/usr/bin/env python3
from bot import Bot
from engines import censorship, commands
from config import getConfiguration


newbot = Bot(getConfiguration("bot"))

# newbot.loadEngine(censorship.CensorshipEngine)
newbot.loadEngine(commands.PermissionEngine)
newbot.loadEngine(commands.CommandsEngine)

cmds = []

from commands.basic import Say, Help, Die, cnJoke, Ping
cmds.extend((Say, Help, Die, cnJoke, Ping))

from commands.fun import asciiClock, cowsay, slap, Dice
cmds.extend((asciiClock, cowsay, slap, Dice))

from commands.taiiwoport import cleverbot, findIP, FindPhone, Love, Moustache, WolframAlphaPlain, WolframAlphaImage, Joke, WYR, Fact
cmds.extend((cleverbot, findIP, FindPhone, Love, Moustache, WolframAlphaPlain, WolframAlphaImage, Joke, WYR, Fact))

from commands.utils import Permission, DeleteLastMessage
cmds.extend((Permission, DeleteLastMessage))

for cmd in cmds:
    cmd(newbot.getEngine("commands"))

newbot.start(1/30)
开发者ID:Mitame,项目名称:Slack-B2,代码行数:32,代码来源:main.py

示例5: range

# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import start [as 别名]
#!/usr/bin/python

from bot import Bot

if __name__ == "__main__":

    bots = []

    for i in range(0, 20):
        b = Bot(ip)
        b.start()

        bots.append(b)

    for b in bots:
        b.join()
开发者ID:jon-stewart,项目名称:mud,代码行数:18,代码来源:stress_test.py

示例6: main

# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import start [as 别名]
def main():
    DIR = os.path.join(os.path.dirname(__file__), "botTest")
    TOCKEN_PATH = os.path.join(DIR, "token")
    LOGGING_PATH = os.path.join(os.path.join(os.path.dirname(__file__), "logs"), "config.json")
    PRIVATE_KEY_PATH = os.path.join(DIR, "private.key")
    PUBLIC_KEY_PATH = os.path.join(DIR, "public.pem")
    purge, webhook_url, install = parse()
    if install != None:
        if not os.path.exists(DIR):
            os.mkdir(DIR)
        with open(TOCKEN_PATH, "w") as f:
            f.write(install + "\n")
        print("End installing")
        return

    if os.path.exists(LOGGING_PATH):
        with open(LOGGING_PATH, "rt") as f:
            config = json.load(f)
        logging.config.dictConfig(config)
    else:
        logging.basicConfig(level=logging.DEBUG)

    with open(TOCKEN_PATH, "r") as f:
        token = f.readline()[:-1]
    bot = Bot(token, DIR)
    if purge:
        bot.purge()
        return
    server = None
    if webhook_url:
        if not os.path.exists(PUBLIC_KEY_PATH):
            print("No public key, please run ssl.sh before !")
            return
        if not os.path.exists(PRIVATE_KEY_PATH):
            print("No private key, please run ssl.sh before !")
            return
        server = WebHookServer(bot, PUBLIC_KEY_PATH, PRIVATE_KEY_PATH, webhook_url)
    else:
        server = PollingServer(bot)
    print("### Start bot...")
    bot.start()
    print("### Bot started")
    print("### Start server...")
    server.start()
    print("### Server started")
    try:
        while True:
            time.sleep(60 * 60)
    except KeyboardInterrupt:
        pass
    print("### Stop server...")
    server.stop()
    print("### Server stopped")
    print("### Stop bot...")
    bot.stop()
    print("### Bot stopped")
    print("### Join server...")
    server.join()
    print("### Server joined")
    print("### Join bot...")
    bot.join()
    print("### Bot joined")
    print("### End of main")
开发者ID:mamaddeveloper,项目名称:teleadmin,代码行数:65,代码来源:main.py


注:本文中的bot.Bot.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。