本文整理汇总了Python中bot.Bot.purge方法的典型用法代码示例。如果您正苦于以下问题:Python Bot.purge方法的具体用法?Python Bot.purge怎么用?Python Bot.purge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bot.Bot
的用法示例。
在下文中一共展示了Bot.purge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import purge [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")