nxy/nxy/bot.py

41 lines
844 B
Python

# -*- coding: utf-8 -*-
import json
import sys
import os
# noinspection PyPackageRequirements
from dotenv import load_dotenv
from irc3 import IrcBot
CFG_DEV = {
'nick': 'nxy',
'autojoins': ['#dev'],
'host': 'localhost',
'port': 6667,
'ssl': False,
'raw': True,
'debug': True,
'verbose': True,
'irc3.plugins.command.masks': {
'*!admin@127.0.0.1': 'all_permissions',
'*': 'view',
}
}
# TODO: imdb, pay, owe, rape (owe), ddg, regex
def main(cfg_file):
load_dotenv('.env')
with open(cfg_file, 'r') as fp:
cfg = json.load(fp)
if bool(os.environ.get('DEV')):
cfg.update(CFG_DEV)
elif 'PASSWORD' in os.environ:
cfg['password'] = os.environ['PASSWORD']
bot = IrcBot.from_config(cfg)
bot.run()
if __name__ == '__main__':
main(sys.argv[1])