From 7c7b63634b4638dea81da54ac1a4a1411edce63b Mon Sep 17 00:00:00 2001 From: nemunaire Date: Sat, 3 Jan 2015 20:34:44 +0100 Subject: [PATCH] [wip] in modules, changes import to reflect new directory structure --- modules/alias.py | 4 ++-- modules/birthday.py | 8 ++++---- modules/bonneannee.py | 4 ++-- modules/books.py | 4 ++-- modules/cmd_server.py | 12 ++++++------ modules/conjugaison.py | 10 ++++------ modules/cve.py | 3 +-- modules/ddg/DDGSearch.py | 4 ++-- modules/ddg/UrbanDictionnary.py | 2 +- modules/ddg/WFASearch.py | 2 +- modules/ddg/__init__.py | 2 +- modules/events.py | 8 ++++---- modules/github.py | 4 ++-- modules/imdb.py | 4 ++-- modules/man.py | 2 +- modules/mapquest.py | 4 ++-- modules/mediawiki.py | 4 ++-- modules/more.py | 6 +++--- modules/networking/__init__.py | 2 +- modules/networking/isup.py | 2 +- modules/networking/page.py | 4 ++-- modules/networking/w3c.py | 4 +++- modules/networking/watchWebsite.py | 7 ++++--- modules/networking/whois.py | 5 +++-- modules/nextstop/__init__.py | 2 +- modules/reddit.py | 4 ++-- modules/rnd.py | 2 +- modules/sap.py | 6 +++--- modules/sleepytime.py | 2 +- modules/sms.py | 2 +- modules/speak.py | 6 +++--- modules/spell/__init__.py | 2 +- modules/syno.py | 4 ++-- modules/tpb.py | 8 ++++---- modules/translate.py | 4 ++-- modules/velib.py | 4 ++-- modules/weather.py | 6 +++--- modules/worldcup.py | 4 ++-- modules/ycc.py | 6 +++--- 39 files changed, 87 insertions(+), 86 deletions(-) diff --git a/modules/alias.py b/modules/alias.py index 61234c1..6df4fcb 100644 --- a/modules/alias.py +++ b/modules/alias.py @@ -7,8 +7,8 @@ import sys from datetime import datetime, timezone import shlex -from hooks import hook -from message import TextMessage, Command +from nemubot.hooks import hook +from nemubot.message import TextMessage, Command nemubotversion = 3.4 diff --git a/modules/birthday.py b/modules/birthday.py index c48ace5..45c08b3 100644 --- a/modules/birthday.py +++ b/modules/birthday.py @@ -6,10 +6,10 @@ import re import sys from datetime import date, datetime -from hooks import hook -from tools.countdown import countdown_format -from tools.date import extractDate -from tools.xmlparser.node import ModuleState +from nemubot.hooks import hook +from nemubot.tools.countdown import countdown_format +from nemubot.tools.date import extractDate +from nemubot.tools.xmlparser.node import ModuleState nemubotversion = 3.4 diff --git a/modules/bonneannee.py b/modules/bonneannee.py index f29b6c4..174072c 100644 --- a/modules/bonneannee.py +++ b/modules/bonneannee.py @@ -4,8 +4,8 @@ from datetime import datetime, timezone -from hooks import hook -from tools.countdown import countdown_format +from nemubot.hooks import hook +from nemubot.tools.countdown import countdown_format nemubotversion = 3.4 diff --git a/modules/books.py b/modules/books.py index de4a9bf..b7f820c 100644 --- a/modules/books.py +++ b/modules/books.py @@ -4,8 +4,8 @@ import urllib -from hooks import hook -from tools import web +from nemubot.hooks import hook +from nemubot.tools import web nemubotversion = 3.4 diff --git a/modules/cmd_server.py b/modules/cmd_server.py index 449f4da..30c08c3 100644 --- a/modules/cmd_server.py +++ b/modules/cmd_server.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Nemubot is a modulable IRC bot, built around XML configuration files. -# Copyright (C) 2012 Mercier Pierre-Olivier +# 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 @@ -19,10 +19,10 @@ import traceback import sys -from prompt.error import PromptError -from hooks import hook -from message import TextMessage -from networkbot import NetworkBot +from nemubot.prompt.error import PromptError +from nemubot.hooks import hook +from nemubot.message import TextMessage +from nemubot.networkbot import NetworkBot nemubotversion = 3.4 NODATA = True diff --git a/modules/conjugaison.py b/modules/conjugaison.py index 4347603..50068b6 100644 --- a/modules/conjugaison.py +++ b/modules/conjugaison.py @@ -2,15 +2,13 @@ """Find french conjugaison""" +from collections import defaultdict import re -import traceback -import sys from urllib.parse import quote -from hooks import hook -from tools import web -from tools.web import striphtml -from collections import defaultdict +from nemubot.hooks import hook +from nemubot.tools import web +from nemubot.tools.web import striphtml nemubotversion = 3.4 diff --git a/modules/cve.py b/modules/cve.py index bfd6c98..e02bc55 100644 --- a/modules/cve.py +++ b/modules/cve.py @@ -1,7 +1,7 @@ import urllib.request from bs4 import BeautifulSoup import pprint -from hooks import hook +from nemubot.hooks import hook from more import Response nemubotversion = 3.4 @@ -34,4 +34,3 @@ def get_cve_desc(msg): desc = soup.body.findAll('td') return Response(desc[DESC_INDEX].text, msg.channel) - diff --git a/modules/ddg/DDGSearch.py b/modules/ddg/DDGSearch.py index 7a79c14..e681d8d 100644 --- a/modules/ddg/DDGSearch.py +++ b/modules/ddg/DDGSearch.py @@ -2,8 +2,8 @@ from urllib.parse import quote -from tools import web -from tools.xmlparser import parse_string +from nemubot.tools import web +from nemubot.tools.xmlparser import parse_string class DDGSearch: diff --git a/modules/ddg/UrbanDictionnary.py b/modules/ddg/UrbanDictionnary.py index 439b313..25faf39 100644 --- a/modules/ddg/UrbanDictionnary.py +++ b/modules/ddg/UrbanDictionnary.py @@ -2,7 +2,7 @@ from urllib.parse import quote -from tools import web +from nemubot.tools import web class UrbanDictionnary: diff --git a/modules/ddg/WFASearch.py b/modules/ddg/WFASearch.py index f465165..f20bbe2 100644 --- a/modules/ddg/WFASearch.py +++ b/modules/ddg/WFASearch.py @@ -2,7 +2,7 @@ from urllib.parse import quote -from tools import web +from nemubot.tools import web class WFASearch: diff --git a/modules/ddg/__init__.py b/modules/ddg/__init__.py index cc61eb5..94e3587 100644 --- a/modules/ddg/__init__.py +++ b/modules/ddg/__init__.py @@ -4,7 +4,7 @@ import imp -from hooks import hook +from nemubot.hooks import hook nemubotversion = 3.4 diff --git a/modules/events.py b/modules/events.py index ce2dae3..6fbee00 100644 --- a/modules/events.py +++ b/modules/events.py @@ -10,10 +10,10 @@ import time import threading import traceback -from event import ModuleEvent -from hooks import hook -from tools.date import extractDate -from tools.countdown import countdown_format, countdown +from nemubot.event import ModuleEvent +from nemubot.hooks import hook +from nemubot.tools.date import extractDate +from nemubot.tools.countdown import countdown_format, countdown nemubotversion = 3.4 diff --git a/modules/github.py b/modules/github.py index d22b832..82a6e75 100644 --- a/modules/github.py +++ b/modules/github.py @@ -5,8 +5,8 @@ import re from urllib.parse import quote -from hooks import hook -from tools import web +from nemubot.hooks import hook +from nemubot.tools import web nemubotversion = 3.4 diff --git a/modules/imdb.py b/modules/imdb.py index 7ae4163..552d98e 100644 --- a/modules/imdb.py +++ b/modules/imdb.py @@ -5,8 +5,8 @@ import re import urllib.parse -from hooks import hook -from tools import web +from nemubot.hooks import hook +from nemubot.tools import web nemubotversion = 3.4 diff --git a/modules/man.py b/modules/man.py index 2e897a3..9dc12a8 100644 --- a/modules/man.py +++ b/modules/man.py @@ -6,7 +6,7 @@ import subprocess import re import os -from hooks import hook +from nemubot.hooks import hook nemubotversion = 3.4 diff --git a/modules/mapquest.py b/modules/mapquest.py index 4f51d49..6ff8a2f 100644 --- a/modules/mapquest.py +++ b/modules/mapquest.py @@ -5,7 +5,7 @@ import re from urllib.parse import quote -from tools import web +from nemubot.tools import web nemubotversion = 3.4 @@ -20,7 +20,7 @@ def load(context): "http://developer.mapquest.com/") return None - from hooks.messagehook import MessageHook + from nemubot.hooks.messagehook import MessageHook add_hook("cmd_hook", MessageHook(cmd_geocode, "geocode")) diff --git a/modules/mediawiki.py b/modules/mediawiki.py index e483a60..6a9232a 100644 --- a/modules/mediawiki.py +++ b/modules/mediawiki.py @@ -6,8 +6,8 @@ import json import re import urllib.parse -from hooks import hook -from tools import web +from nemubot.hooks import hook +from nemubot.tools import web nemubotversion = 3.4 diff --git a/modules/more.py b/modules/more.py index a8dbd4f..72c5864 100644 --- a/modules/more.py +++ b/modules/more.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # 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 # it under the terms of the GNU Affero General Public License as published by @@ -20,8 +20,8 @@ import logging -from message import TextMessage, DirectAsk -from hooks import hook +from nemubot.message import TextMessage, DirectAsk +from nemubot.hooks import hook nemubotversion = 3.4 diff --git a/modules/networking/__init__.py b/modules/networking/__init__.py index 3371a09..d3e515e 100644 --- a/modules/networking/__init__.py +++ b/modules/networking/__init__.py @@ -2,7 +2,7 @@ """Various network tools (w3m, w3c validator, curl, traceurl, ...)""" -from hooks import hook +from nemubot.hooks import hook nemubotversion = 3.4 diff --git a/modules/networking/isup.py b/modules/networking/isup.py index f400381..f20276c 100644 --- a/modules/networking/isup.py +++ b/modules/networking/isup.py @@ -1,6 +1,6 @@ import urllib -from tools.web import getJSON +from nemubot.tools.web import getJSON def isup(url): """Determine if the given URL is up or not diff --git a/modules/networking/page.py b/modules/networking/page.py index df561e0..3155e58 100644 --- a/modules/networking/page.py +++ b/modules/networking/page.py @@ -4,8 +4,8 @@ import subprocess import tempfile import urllib -from bot import __version__ -from tools import web +from nemubot import __version__ +from nemubot.tools import web def load(CONF, add_hook): diff --git a/modules/networking/w3c.py b/modules/networking/w3c.py index db10753..3e145f3 100644 --- a/modules/networking/w3c.py +++ b/modules/networking/w3c.py @@ -1,6 +1,8 @@ import json import urllib +from nemubot import __version__ + def validator(url): """Run the w3c validator on the given URL @@ -15,7 +17,7 @@ def validator(url): raise IRCException("Indiquer une URL valide !") try: - req = urllib.request.Request("http://validator.w3.org/check?uri=%s&output=json" % (urllib.parse.quote(o.geturl())), headers={ 'User-Agent' : "nemubot v3" }) + req = urllib.request.Request("http://validator.w3.org/check?uri=%s&output=json" % (urllib.parse.quote(o.geturl())), headers={ 'User-Agent' : "Nemubot v%s" % __version__}) raw = urllib.request.urlopen(req, timeout=10) except urllib.error.HTTPError as e: raise IRCException("HTTP error occurs: %s %s" % (e.code, e.reason)) diff --git a/modules/networking/watchWebsite.py b/modules/networking/watchWebsite.py index 7415672..2ebc4a2 100644 --- a/modules/networking/watchWebsite.py +++ b/modules/networking/watchWebsite.py @@ -4,12 +4,13 @@ from random import randint import urllib.parse from urllib.parse import urlparse -from hooks import hook -from more import Response -from tools.xmlparser.node import ModuleState +from nemubot.hooks import hook +from nemubot.tools.xmlparser.node import ModuleState nemubotversion = 3.4 +from more import Response + from .atom import Atom from . import page diff --git a/modules/networking/whois.py b/modules/networking/whois.py index 2ec51ed..1e8d6d5 100644 --- a/modules/networking/whois.py +++ b/modules/networking/whois.py @@ -1,8 +1,9 @@ import datetime import urllib +from nemubot.tools.web import getJSON + from more import Response -from tools.web import getJSON URL_WHOIS = "http://www.whoisxmlapi.com/whoisserver/WhoisService?rid=1&domainName=%%s&outputFormat=json&userName=%s&password=%s" @@ -17,7 +18,7 @@ def load(CONF, add_hook): else: URL_WHOIS = URL_WHOIS % (urllib.parse.quote(CONF.getNode("whoisxmlapi")["username"]), urllib.parse.quote(CONF.getNode("whoisxmlapi")["password"])) - from hooks.messagehook import MessageHook + from nemubot.hooks.messagehook import MessageHook add_hook("cmd_hook", MessageHook(cmd_whois, "netwhois")) diff --git a/modules/nextstop/__init__.py b/modules/nextstop/__init__.py index f53aec4..5a54724 100644 --- a/modules/nextstop/__init__.py +++ b/modules/nextstop/__init__.py @@ -2,7 +2,7 @@ """Informe les usagers des prochains passages des transports en communs de la RATP""" -from hooks import hook +from nemubot.hooks import hook from more import Response nemubotversion = 3.4 diff --git a/modules/reddit.py b/modules/reddit.py index 3b47bf0..786e5b0 100644 --- a/modules/reddit.py +++ b/modules/reddit.py @@ -4,11 +4,11 @@ import re -from tools import web +from nemubot.hooks import hook +from nemubot.tools import web nemubotversion = 3.4 -from hooks import hook from more import Response diff --git a/modules/rnd.py b/modules/rnd.py index 9cae89c..ddaa8c2 100644 --- a/modules/rnd.py +++ b/modules/rnd.py @@ -4,7 +4,7 @@ import random -from hooks import hook +from nemubot.hooks import hook nemubotversion = 3.4 diff --git a/modules/sap.py b/modules/sap.py index 81eccea..4067aae 100644 --- a/modules/sap.py +++ b/modules/sap.py @@ -5,9 +5,9 @@ import re import urllib.parse -from hooks import hook -from tools import web -from tools.web import striphtml +from nemubot.hooks import hook +from nemubot.tools import web +from nemubot.tools.web import striphtml nemubotversion = 3.4 diff --git a/modules/sleepytime.py b/modules/sleepytime.py index d082072..bf72249 100644 --- a/modules/sleepytime.py +++ b/modules/sleepytime.py @@ -6,7 +6,7 @@ import re import imp from datetime import datetime, timedelta, timezone -from hooks import hook +from nemubot.hooks import hook nemubotversion = 3.4 diff --git a/modules/sms.py b/modules/sms.py index f96bfad..9d50386 100644 --- a/modules/sms.py +++ b/modules/sms.py @@ -9,7 +9,7 @@ import urllib.error import urllib.request import urllib.parse -from hooks import hook +from nemubot.hooks import hook nemubotversion = 3.4 diff --git a/modules/speak.py b/modules/speak.py index 2b85035..d8808b8 100644 --- a/modules/speak.py +++ b/modules/speak.py @@ -6,9 +6,9 @@ import re import subprocess from threading import Thread -from hooks import hook -from message import TextMessage -from message.visitor import AbstractVisitor +from nemubot.hooks import hook +from nemubot.message import TextMessage +from nemubot.message.visitor import AbstractVisitor nemubotversion = 3.4 diff --git a/modules/spell/__init__.py b/modules/spell/__init__.py index f63cab5..60bd822 100644 --- a/modules/spell/__init__.py +++ b/modules/spell/__init__.py @@ -5,7 +5,7 @@ import re from urllib.parse import quote -from hooks import hook +from nemubot.hooks import hook from .pyaspell import Aspell from .pyaspell import AspellError diff --git a/modules/syno.py b/modules/syno.py index 5747c29..580ef46 100644 --- a/modules/syno.py +++ b/modules/syno.py @@ -5,8 +5,8 @@ import re from urllib.parse import quote -from hooks import hook -from tools import web +from nemubot.hooks import hook +from nemubot.tools import web nemubotversion = 3.4 diff --git a/modules/tpb.py b/modules/tpb.py index 4cc1187..c1d1ad3 100644 --- a/modules/tpb.py +++ b/modules/tpb.py @@ -1,12 +1,12 @@ from datetime import datetime import urllib -from tools import human -from tools.web import getJSON +from nemubot.hooks import hook +from nemubot.tools import human +from nemubot.tools.web import getJSON nemubotversion = 3.4 -from hooks import hook from more import Response URL_TPBAPI = None @@ -22,7 +22,7 @@ def load(context): else: URL_TPBAPI = CONF.getNode("tpbapi")["url"] - from hooks.messagehook import MessageHook + from nemubot.hooks.messagehook import MessageHook add_hook("cmd_hook", MessageHook(cmd_tpb, "tpb")) diff --git a/modules/translate.py b/modules/translate.py index 6e0b825..538f04e 100644 --- a/modules/translate.py +++ b/modules/translate.py @@ -5,7 +5,7 @@ import re from urllib.parse import quote -from tools import web +from nemubot.tools import web nemubotversion = 3.4 @@ -27,7 +27,7 @@ def load(context): else: URL = URL % CONF.getNode("wrapi")["key"] - from hooks.messagehook import MessageHook + from nemubot.hooks.messagehook import MessageHook add_hook("cmd_hook", MessageHook(cmd_translate, "translate")) diff --git a/modules/velib.py b/modules/velib.py index f45372d..ed22117 100644 --- a/modules/velib.py +++ b/modules/velib.py @@ -4,8 +4,8 @@ import re -from hooks import hook -from tools import web +from nemubot.hooks import hook +from nemubot.tools import web nemubotversion = 3.4 diff --git a/modules/weather.py b/modules/weather.py index 6df1882..a5fbc2d 100644 --- a/modules/weather.py +++ b/modules/weather.py @@ -6,8 +6,8 @@ import datetime import re from urllib.parse import quote -from hooks import hook -from tools import web +from nemubot.hooks import hook +from nemubot.tools import web import mapquest @@ -27,7 +27,7 @@ def load(context): "http://developer.forecast.io/") return None - from hooks.messagehook import MessageHook + from nemubot.hooks.messagehook import MessageHook add_hook("cmd_hook", MessageHook(cmd_weather, "météo")) add_hook("cmd_hook", MessageHook(cmd_alert, "alert")) add_hook("cmd_hook", MessageHook(cmd_coordinates, "coordinates")) diff --git a/modules/worldcup.py b/modules/worldcup.py index 2426c7c..d95d884 100644 --- a/modules/worldcup.py +++ b/modules/worldcup.py @@ -8,12 +8,12 @@ import re from urllib.parse import quote from urllib.request import urlopen +from nemubot.hooks import hook + nemubotversion = 3.4 from more import Response -from hooks import hook - API_URL="http://worldcup.sfg.io/%s" def load(context): diff --git a/modules/ycc.py b/modules/ycc.py index 0a42fc3..60b02f6 100644 --- a/modules/ycc.py +++ b/modules/ycc.py @@ -6,9 +6,9 @@ import re from urllib.parse import urlparse from urllib.parse import quote -from hooks import hook -from message import TextMessage -from tools import web +from nemubot.hooks import hook +from nemubot.message import TextMessage +from nemubot.tools import web nemubotversion = 3.4