boots/boots/boots.py
Elijah Lazkani 2072e53144 This change introduces better logging for the bot
You can configure the logging system by configuring config/logging.yaml
2017-09-16 12:05:41 -04:00

70 lines
No EOL
1.8 KiB
Python

import logging
import asyncio
import robot
import eightball
import admin
import admin_commands
from logger import setup_logging
setup_logging("./config/logging.yaml")
logger = logging.getLogger(__name__)
async def plugins(bot: robot.Bot):
magic_ball = eightball.EightBall(bot)
@magic_ball.on_keyword
async def ball(target, message, **kwargs):
bot.send("PRIVMSG", target=target, message=message)
administrator = admin.Admin(bot)
await administrator.init()
admin_cmd = admin_commands.AdminCmd(administrator)
@admin_cmd.on_command("join")
def join(target, message, **kwargs):
bot.send("JOIN", channel=message)
@admin_cmd.on_command("part")
def part(target, message, **kwargs):
bot.send("PART", channel=message)
@admin_cmd.on_command("msg")
def msg(target, message, **kwargs):
kwargs['target'] = message.split(' ')[0]
kwargs['message'] = " ".join(message.split(' ')[1:])
bot.send("PRIVMSG", **kwargs)
@admin_cmd.on_command("action")
def action(target, message, **kwargs):
kwargs['target'] = message.split(' ')[0]
kwargs['message'] = "\x01ACTION {}\x01".format(" ".join(message.split(' ')[1:]))
bot.send("PRIVMSG", **kwargs)
@admin_cmd.on_command("quit")
async def quit(target, message, **kwargs):
bot.send("QUIT", message=message)
await bot.disconnect()
# Exit the event loop cleanly
bot.loop.stop()
def main():
host = 'eu.undernet.org'
port = 6667
ssl = False
nick = "LuckyBoots"
channel = "#msaytbeh"
bot = robot.Bot(host=host, port=port, ssl=ssl, nick=nick, channels=[channel])
bot.loop.create_task(bot.connect())
asyncio.ensure_future(plugins(bot))
bot.loop.run_forever()
bot.loop.close()
if __name__ == '__main__':
main()