[wip] changes import to reflect new directory structure

This commit is contained in:
nemunaire 2015-01-03 20:17:46 +01:00
parent 41f7dc2456
commit 5a6230d844
31 changed files with 202 additions and 174 deletions

View File

@ -1,8 +1,8 @@
#!/usr/bin/env python3.2 #!/usr/bin/env python3.3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -23,11 +23,11 @@ import logging
import os import os
import sys import sys
import bot import nemubot
import prompt import nemubot.prompt as prompt
from prompt.builtins import load_file from nemubot.prompt.builtins import load_file
from prompt.reset import PromptReset from nemubot.prompt.reset import PromptReset
import importer from nemubot.importer import ModuleFinder
if __name__ == "__main__": if __name__ == "__main__":
# Parse command line arguments # Parse command line arguments
@ -59,7 +59,7 @@ if __name__ == "__main__":
args = parser.parse_args() args = parser.parse_args()
if args.version: if args.version:
print(bot.__version__) print(nemubot.__version__)
sys.exit(0) sys.exit(0)
# Setup loggin interface # Setup loggin interface
@ -91,7 +91,7 @@ if __name__ == "__main__":
logger.error("%s is not a directory", path) logger.error("%s is not a directory", path)
# Create bot context # Create bot context
context = bot.Bot(modules_paths=modules_paths, data_path=args.data_path, context = nemubot.Bot(modules_paths=modules_paths, data_path=args.data_path,
verbosity=args.verbose) verbosity=args.verbose)
if args.no_connect: if args.no_connect:
@ -101,7 +101,7 @@ if __name__ == "__main__":
prmpt = prompt.Prompt() prmpt = prompt.Prompt()
# Register the hook for futur import # Register the hook for futur import
sys.meta_path.append(importer.ModuleFinder(context, prmpt)) sys.meta_path.append(ModuleFinder(context, prmpt))
# Load requested configuration files # Load requested configuration files
for path in args.files: for path in args.files:
@ -114,7 +114,7 @@ if __name__ == "__main__":
for module in args.module: for module in args.module:
__import__(module) __import__(module)
print ("Nemubot v%s ready, my PID is %i!" % (bot.__version__, print ("Nemubot v%s ready, my PID is %i!" % (nemubot.__version__,
os.getpid())) os.getpid()))
context.start() context.start()
while True: while True:
@ -127,14 +127,14 @@ if __name__ == "__main__":
try: try:
# Reload context # Reload context
imp.reload(bot) imp.reload(bot)
context = bot.hotswap(context) context = nemubot.hotswap(context)
# Reload prompt # Reload prompt
imp.reload(prompt) imp.reload(prompt)
prmpt = prompt.hotswap(prmpt) prmpt = prompt.hotswap(prmpt)
# Reload all other modules # Reload all other modules
bot.reload() nemubot.reload()
print("\033[1;32mContext reloaded\033[0m, now in Nemubot %s" % print("\033[1;32mContext reloaded\033[0m, now in Nemubot %s" %
bot.__version__) nemubot.__version__)
context.start() context.start()
except: except:
logger.exception("\033[1;31mUnable to reload the prompt due to " logger.exception("\033[1;31mUnable to reload the prompt due to "

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -27,16 +27,16 @@ import threading
import time import time
import uuid import uuid
__version__ = '3.4.dev4' __version__ = '4.0.dev0'
__author__ = 'nemunaire' __author__ = 'nemunaire'
from consumer import Consumer, EventConsumer, MessageConsumer from nemubot.consumer import Consumer, EventConsumer, MessageConsumer
from event import ModuleEvent from nemubot.event import ModuleEvent
from hooks.messagehook import MessageHook from nemubot.hooks.messagehook import MessageHook
from hooks.manager import HooksManager from nemubot.hooks.manager import HooksManager
from networkbot import NetworkBot from nemubot.networkbot import NetworkBot
logger = logging.getLogger("nemubot.bot") logger = logging.getLogger("nemubot")
class Bot(threading.Thread): class Bot(threading.Thread):
@ -129,7 +129,7 @@ class Bot(threading.Thread):
def run(self): def run(self):
from server import _rlist, _wlist, _xlist from nemubot.server import _rlist, _wlist, _xlist
self.stop = False self.stop = False
while not self.stop: while not self.stop:
@ -453,44 +453,44 @@ def hotswap(bak):
return new return new
def reload(): def reload():
import channel import nemubot.channel
imp.reload(channel) imp.reload(nemubot.channel)
import consumer import nemubot.consumer
imp.reload(consumer) imp.reload(nemubot.consumer)
import event import nemubot.event
imp.reload(event) imp.reload(nemubot.event)
import exception import nemubot.exception
imp.reload(exception) imp.reload(nemubot.exception)
import hooks import nemubot.hooks
imp.reload(hooks) imp.reload(nemubot.hooks)
hooks.reload() nemubot.hooks.reload()
import importer import nemubot.importer
imp.reload(importer) imp.reload(nemubot.importer)
import message import nemubot.message
imp.reload(message) imp.reload(nemubot.message)
message.reload() nemubot.message.reload()
import prompt import nemubot.prompt
imp.reload(prompt) imp.reload(nemubot.prompt)
prompt.reload() nemubot.prompt.reload()
import server import nemubot.server
rl, wl, xl = server._rlist, server._wlist, server._xlist rl, wl, xl = nemubot.server._rlist, nemubot.server._wlist, nemubot.server._xlist
imp.reload(server) imp.reload(nemubot.server)
server._rlist, server._wlist, server._xlist = rl, wl, xl nemubot.server._rlist, nemubot.server._wlist, nemubot.server._xlist = rl, wl, xl
server.reload() nemubot.server.reload()
import tools import nemubot.tools
imp.reload(tools) imp.reload(nemubot.tools)
tools.reload() nemubot.tools.reload()

View File

@ -1,7 +1,7 @@
# coding=utf-8 # coding=utf-8
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -18,6 +18,7 @@
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta, timezone
class ModuleEvent: class ModuleEvent:
"""Representation of a event initiated by a bot module""" """Representation of a event initiated by a bot module"""
@ -71,7 +72,6 @@ class ModuleEvent:
# How many times do this event? # How many times do this event?
self.times = times self.times = times
@property @property
def current(self): def current(self):
"""Return the date of the near check""" """Return the date of the near check"""
@ -81,7 +81,6 @@ class ModuleEvent:
return self._end return self._end
return None return None
@property @property
def next(self): def next(self):
"""Return the date of the next check""" """Return the date of the next check"""
@ -93,14 +92,12 @@ class ModuleEvent:
return self._end return self._end
return None return None
@property @property
def time_left(self): def time_left(self):
"""Return the time left before/after the near check""" """Return the time left before/after the near check"""
if self.current is not None: if self.current is not None:
return self.current - datetime.now(timezone.utc) return self.current - datetime.now(timezone.utc)
return 99999 #TODO: 99999 is not a valid time to return return 99999 # TODO: 99999 is not a valid time to return
def check(self): def check(self):
"""Run a check and realized the event if this is time""" """Run a check and realized the event if this is time"""

View File

@ -1,7 +1,7 @@
# coding=utf-8 # coding=utf-8
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -16,7 +16,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from message import TextMessage, DirectAsk from nemubot.message import TextMessage, DirectAsk
class IRCException(Exception): class IRCException(Exception):

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -18,7 +18,7 @@
import imp import imp
from exception import IRCException from nemubot.exception import IRCException
def call_game(call, *args, **kargs): def call_game(call, *args, **kargs):
@ -67,7 +67,7 @@ class AbstractHook:
return ret return ret
from hooks.messagehook import MessageHook from nemubot.hooks.messagehook import MessageHook
last_registered = [] last_registered = []
@ -81,8 +81,8 @@ def hook(store, *args, **kargs):
def reload(): def reload():
import hooks.manager import nemubot.hooks.manager
imp.reload(hooks.manager) imp.reload(nemubot.hooks.manager)
import hooks.messagehook import nemubot.hooks.messagehook
imp.reload(hooks.messagehook) imp.reload(nemubot.hooks.messagehook)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -18,19 +18,19 @@
import re import re
from exception import IRCException from nemubot.exception import IRCException
import hooks from nemubot.hooks import AbstractHook
import message import nemubot.message
class MessageHook(hooks.AbstractHook): class MessageHook(AbstractHook):
"""Class storing hook information, specialized for a generic Message""" """Class storing hook information, specialized for a generic Message"""
def __init__(self, call, name=None, data=None, regexp=None, def __init__(self, call, name=None, data=None, regexp=None,
channels=list(), server=None, mtimes=-1, end_call=None): channels=list(), server=None, mtimes=-1, end_call=None):
hooks.AbstractHook.__init__(self, call=call, data=data, AbstractHook.__init__(self, call=call, data=data,
end_call=end_call, mtimes=mtimes) end_call=end_call, mtimes=mtimes)
self.name = name self.name = name
@ -40,12 +40,12 @@ class MessageHook(hooks.AbstractHook):
def match(self, msg, server=None): def match(self, msg, server=None):
if not isinstance(msg, message.AbstractMessage): if not isinstance(msg, nemubot.message.AbstractMessage):
return True return True
elif isinstance(msg, message.Command): elif isinstance(msg, nemubot.message.Command):
return self.is_matching(msg.cmd, msg.to, server) return self.is_matching(msg.cmd, msg.to, server)
elif isinstance(msg, message.TextMessage): elif isinstance(msg, nemubot.message.TextMessage):
return self.is_matching(msg.message, msg.to, server) return self.is_matching(msg.message, msg.to, server)
else: else:
return False return False

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -24,16 +24,18 @@ import logging
import os import os
import sys import sys
from bot import __version__ from nemubot import __version__
import event from nemubot.event import ModuleEvent
import exception from nemubot.exception import IRCException
import hooks import nemubot.hooks
from message import TextMessage from nemubot.message import TextMessage
from tools.xmlparser import parse_file, module_state from nemubot.tools.xmlparser import parse_file, module_state
logger = logging.getLogger("nemubot.importer") logger = logging.getLogger("nemubot.importer")
class ModuleFinder(Finder): class ModuleFinder(Finder):
def __init__(self, context, prompt): def __init__(self, context, prompt):
self.context = context self.context = context
self.prompt = prompt self.prompt = prompt
@ -151,9 +153,9 @@ class ModuleLoader(SourceFileLoader):
module.save = lambda: False module.save = lambda: False
module.CONF = self.config module.CONF = self.config
module.ModuleEvent = event.ModuleEvent module.ModuleEvent = ModuleEvent
module.ModuleState = module_state.ModuleState module.ModuleState = module_state.ModuleState
module.IRCException = exception.IRCException module.IRCException = IRCException
# Load dependancies # Load dependancies
if module.CONF is not None and module.CONF.hasNode("dependson"): if module.CONF is not None and module.CONF.hasNode("dependson"):
@ -213,7 +215,7 @@ def register_hooks(module, context, prompt):
""" """
# Register decorated functions # Register decorated functions
for s, h in hooks.last_registered: for s, h in nemubot.hooks.last_registered:
if s == "prompt_cmd": if s == "prompt_cmd":
prompt.add_cap_hook(h.name, h.call) prompt.add_cap_hook(h.name, h.call)
elif s == "prompt_list": elif s == "prompt_list":
@ -222,4 +224,4 @@ def register_hooks(module, context, prompt):
s = convert_legacy_store(s) s = convert_legacy_store(s)
module.REGISTERED_HOOKS.append((s, h)) module.REGISTERED_HOOKS.append((s, h))
context.hooks.add_hook(h, s) context.hooks.add_hook(h, s)
hooks.last_registered = [] nemubot.hooks.last_registered = []

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -166,10 +166,10 @@ class OwnerCommand(Command):
def reload(): def reload():
import message.visitor import nemubot.message.visitor
imp.reload(message.visitor) imp.reload(nemubot.message.visitor)
import message.printer import nemubot.message.printer
imp.reload(message.printer) imp.reload(nemubot.message.printer)
message.printer.reload() nemubot.message.printer.reload()

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -16,8 +16,8 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from message import TextMessage from nemubot.message import TextMessage
from message.visitor import AbstractVisitor from nemubot.message.visitor import AbstractVisitor
class IRC(AbstractVisitor): class IRC(AbstractVisitor):

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -20,5 +20,5 @@ import imp
def reload(): def reload():
import message.printer.IRC import nemubot.message.printer.IRC
imp.reload(message.printer.IRC) imp.reload(nemubot.message.printer.IRC)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -22,8 +22,8 @@ import shlex
import urllib.parse import urllib.parse
import zlib import zlib
from server.DCC import DCC from nemubot.server.DCC import DCC
import hooks import nemubot.hooks as hooks
class NetworkBot: class NetworkBot:
def __init__(self, context, srv, dest, dcc=None): def __init__(self, context, srv, dest, dcc=None):

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -23,9 +23,9 @@ import shlex
import sys import sys
import traceback import traceback
from .error import PromptError from nemubot.prompt.error import PromptError
from .reset import PromptReset from nemubot.prompt.reset import PromptReset
from . import builtins from nemubot.prompt import builtins
class Prompt: class Prompt:
@ -134,5 +134,11 @@ def hotswap(bak):
def reload(): def reload():
import prompt.builtins import nemubot.prompt.builtins
imp.reload(prompt.builtins) imp.reload(nemubot.prompt.builtins)
import nemubot.prompt.error
imp.reload(nemubot.prompt.error)
import nemubot.prompt.reset
imp.reload(nemubot.prompt.reset)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -18,8 +18,8 @@
import logging import logging
from .reset import PromptReset from nemubot.prompt.reset import PromptReset
from tools.config import load_file from nemubot.tools.config import load_file
logger = logging.getLogger("nemubot.prompt.builtins") logger = logging.getLogger("nemubot.prompt.builtins")

View File

@ -1,7 +1,7 @@
# coding=utf-8 # coding=utf-8
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by

View File

@ -1,7 +1,7 @@
# coding=utf-8 # coding=utf-8
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -25,8 +25,8 @@ import time
import threading import threading
import traceback import traceback
import message import nemubot.message as message
import server import nemubot.server as server
#Store all used ports #Store all used ports
PORTS = list() PORTS = list()

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -23,10 +23,10 @@ import re
import time import time
import shlex import shlex
from channel import Channel from nemubot.channel import Channel
import message import nemubot.message as message
from message.printer.IRC import IRC as IRCPrinter from nemubot.message.printer.IRC import IRC as IRCPrinter
from server.socket import SocketServer from nemubot.server.socket import SocketServer
class IRC(SocketServer): class IRC(SocketServer):
@ -97,18 +97,18 @@ class IRC(SocketServer):
self.logger.error("DCC: unable to connect to %s:%d", ip, port) self.logger.error("DCC: unable to connect to %s:%d", ip, port)
return "ERRMSG unable to connect to %s:%d" % (ip, port) return "ERRMSG unable to connect to %s:%d" % (ip, port)
import bot import nemubot
self.ctcp_capabilities["ACTION"] = lambda msg, cmds: print ("ACTION receive: %s" % cmds) self.ctcp_capabilities["ACTION"] = lambda msg, cmds: print ("ACTION receive: %s" % cmds)
self.ctcp_capabilities["CLIENTINFO"] = _ctcp_clientinfo self.ctcp_capabilities["CLIENTINFO"] = _ctcp_clientinfo
#self.ctcp_capabilities["DCC"] = _ctcp_dcc #self.ctcp_capabilities["DCC"] = _ctcp_dcc
self.ctcp_capabilities["FINGER"] = lambda msg, cmds: "VERSION nemubot v%s" % bot.__version__ self.ctcp_capabilities["FINGER"] = lambda msg, cmds: "VERSION nemubot v%s" % nemubot.__version__
self.ctcp_capabilities["NEMUBOT"] = lambda msg, cmds: "NEMUBOT %s" % bot.__version__ self.ctcp_capabilities["NEMUBOT"] = lambda msg, cmds: "NEMUBOT %s" % nemubot.__version__
self.ctcp_capabilities["PING"] = lambda msg, cmds: "PING %s" % " ".join(cmds[1:]) self.ctcp_capabilities["PING"] = lambda msg, cmds: "PING %s" % " ".join(cmds[1:])
self.ctcp_capabilities["SOURCE"] = lambda msg, cmds: "SOURCE https://github.com/nemunaire/nemubot" self.ctcp_capabilities["SOURCE"] = lambda msg, cmds: "SOURCE https://github.com/nemunaire/nemubot"
self.ctcp_capabilities["TIME"] = lambda msg, cmds: "TIME %s" % (datetime.now()) self.ctcp_capabilities["TIME"] = lambda msg, cmds: "TIME %s" % (datetime.now())
self.ctcp_capabilities["USERINFO"] = lambda msg, cmds: "USERINFO %s" % self.realname self.ctcp_capabilities["USERINFO"] = lambda msg, cmds: "USERINFO %s" % self.realname
self.ctcp_capabilities["VERSION"] = lambda msg, cmds: "VERSION nemubot v%s" % bot.__version__ self.ctcp_capabilities["VERSION"] = lambda msg, cmds: "VERSION nemubot v%s" % nemubot.__version__
# TODO: Temporary fix, waiting for hook based CTCP management # TODO: Temporary fix, waiting for hook based CTCP management
self.ctcp_capabilities["TYPING"] = lambda msg, cmds: None self.ctcp_capabilities["TYPING"] = lambda msg, cmds: None

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -154,8 +154,8 @@ class AbstractServer(io.IOBase):
def reload(): def reload():
import server.socket import nemubot.server.socket
imp.reload(server.socket) imp.reload(nemubot.server.socket)
import server.IRC import nemubot.server.IRC
imp.reload(server.IRC) imp.reload(nemubot.server.IRC)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -19,7 +19,7 @@
import ssl import ssl
import socket import socket
from server import AbstractServer from nemubot.server import AbstractServer
class SocketServer(AbstractServer): class SocketServer(AbstractServer):

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -20,16 +20,22 @@ import imp
def reload(): def reload():
import tools.countdown import nemubot.tools.config
imp.reload(tools.countdown) imp.reload(nemubot.tools.config)
import tools.date import nemubot.tools.countdown
imp.reload(tools.date) imp.reload(nemubot.tools.countdown)
import tools.web import nemubot.tools.date
imp.reload(tools.web) imp.reload(nemubot.tools.date)
import tools.xmlparser import nemubot.tools.human
imp.reload(tools.xmlparser) imp.reload(nemubot.tools.human)
import tools.xmlparser.node
imp.reload(tools.xmlparser.node) import nemubot.tools.web
imp.reload(nemubot.tools.web)
import nemubot.tools.xmlparser
imp.reload(nemubot.tools.xmlparser)
import nemubot.tools.xmlparser.node
imp.reload(nemubot.tools.xmlparser.node)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -19,7 +19,7 @@
import logging import logging
import os import os
from tools.xmlparser import parse_file from nemubot.tools.xmlparser import parse_file
logger = logging.getLogger("nemubot.tools.config") logger = logging.getLogger("nemubot.tools.config")
@ -80,7 +80,7 @@ def _load_server(config, xmlnode):
# Bind the protocol asked to the corresponding implementation # Bind the protocol asked to the corresponding implementation
if "protocol" not in xmlnode or xmlnode["protocol"] == "irc": if "protocol" not in xmlnode or xmlnode["protocol"] == "irc":
from server.IRC import IRC as IRCServer from nemubot.server.IRC import IRC as IRCServer
srvcls = IRCServer srvcls = IRCServer
else: else:
raise Exception("Unhandled protocol '%s'" % raise Exception("Unhandled protocol '%s'" %

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a smart and modulable IM bot. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2014 nemunaire # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by

View File

@ -1,7 +1,7 @@
# coding=utf-8 # coding=utf-8
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -25,9 +25,9 @@ from urllib.parse import quote
from urllib.parse import urlparse from urllib.parse import urlparse
from urllib.request import urlopen from urllib.request import urlopen
from bot import __version__ from nemubot import __version__
from exception import IRCException from nemubot.exception import IRCException
from tools.xmlparser import parse_string from nemubot.tools.xmlparser import parse_string
def isURL(url): def isURL(url):

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Nemubot is a modulable IRC bot, built around XML configuration files. # Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012 Mercier Pierre-Olivier # Copyright (C) 2012-2015 Mercier Pierre-Olivier
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -19,12 +19,13 @@
import logging import logging
import xml.sax import xml.sax
from . import node as module_state from nemubot.tools.xmlparser import node as module_state
logger = logging.getLogger("nemubot.tools.xmlparser") logger = logging.getLogger("nemubot.tools.xmlparser")
class ModuleStatesFile(xml.sax.ContentHandler): class ModuleStatesFile(xml.sax.ContentHandler):
def startDocument(self): def startDocument(self):
self.root = None self.root = None
self.stack = list() self.stack = list()

View File

@ -1,5 +1,21 @@
# coding=utf-8 # coding=utf-8
# Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2015 Mercier Pierre-Olivier
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import xml.sax import xml.sax
from datetime import datetime, timezone from datetime import datetime, timezone
import logging import logging