Move most code in root directory to src/
This commit is contained in:
parent
da7e02ffc9
commit
ecb9d7cb3f
64 changed files with 93 additions and 90 deletions
|
@ -1,5 +1,5 @@
|
||||||
import random
|
import random
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
CHOICES = [
|
CHOICES = [
|
||||||
"Definitely",
|
"Definitely",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
_name = "AutoMode"
|
_name = "AutoMode"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
_name = "BTC"
|
_name = "BTC"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import json, re
|
import json, re
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_GOOGLEBOOKS = "https://www.googleapis.com/books/v1/volumes"
|
URL_GOOGLEBOOKS = "https://www.googleapis.com/books/v1/volumes"
|
||||||
URL_BOOKINFO = "https://books.google.co.uk/books?id=%s"
|
URL_BOOKINFO = "https://books.google.co.uk/books?id=%s"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
_name = "Channel Op"
|
_name = "Channel Op"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#--require-config virustotal-api-key
|
#--require-config virustotal-api-key
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_VIRUSTOTAL = "https://www.virustotal.com/vtapi/v2/url/report"
|
URL_VIRUSTOTAL = "https://www.virustotal.com/vtapi/v2/url/report"
|
||||||
RE_URL = re.compile(r"https?://\S+", re.I)
|
RE_URL = re.compile(r"https?://\S+", re.I)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import datetime, decimal, math, random, re, time
|
import datetime, decimal, math, random, re, time
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
SIDES = {"heads": 0, "tails": 1}
|
SIDES = {"heads": 0, "tails": 1}
|
||||||
DEFAULT_REDEEM_DELAY = 600 # 600 seconds, 10 minutes
|
DEFAULT_REDEEM_DELAY = 600 # 600 seconds, 10 minutes
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import re
|
import re
|
||||||
import EventManager, Utils
|
from src import EventManager, Utils
|
||||||
|
|
||||||
STR_MORE = "%s (more...)" % Utils.FONT_RESET
|
STR_MORE = "%s (more...)" % Utils.FONT_RESET
|
||||||
STR_CONTINUED = "(...continued) "
|
STR_CONTINUED = "(...continued) "
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import datetime
|
import datetime
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#--require-config wordnik-api-key
|
#--require-config wordnik-api-key
|
||||||
|
|
||||||
import Utils
|
|
||||||
import time
|
import time
|
||||||
|
from src import Utils
|
||||||
|
|
||||||
URL_WORDNIK = "https://api.wordnik.com/v4/word.json/%s/definitions"
|
URL_WORDNIK = "https://api.wordnik.com/v4/word.json/%s/definitions"
|
||||||
URL_WORDNIK_RANDOM = "https://api.wordnik.com/v4/words.json/randomWord"
|
URL_WORDNIK_RANDOM = "https://api.wordnik.com/v4/words.json/randomWord"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import random
|
import random
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import random
|
import random
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from time import time
|
from time import time
|
||||||
import EventManager
|
from src import EventManager, Utils
|
||||||
|
|
||||||
import Utils
|
|
||||||
|
|
||||||
DUCK_TAIL = "・゜゜・。。・゜゜"
|
DUCK_TAIL = "・゜゜・。。・゜゜"
|
||||||
DUCK_HEAD = ["\_o< ", "\_O< ", "\_0< ", "\_\u00f6< ", "\_\u00f8< ",
|
DUCK_HEAD = ["\_o< ", "\_O< ", "\_0< ", "\_\u00f6< ", "\_\u00f8< ",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import socket
|
import socket
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
EVAL_URL = "https://eval.appspot.com/eval"
|
EVAL_URL = "https://eval.appspot.com/eval"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_GEOIP = "http://ip-api.com/json/%s"
|
URL_GEOIP = "http://ip-api.com/json/%s"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#--require-config google-api-key
|
#--require-config google-api-key
|
||||||
#--require-config google-search-id
|
#--require-config google-search-id
|
||||||
|
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_GOOGLESEARCH = "https://www.googleapis.com/customsearch/v1"
|
URL_GOOGLESEARCH = "https://www.googleapis.com/customsearch/v1"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_HAVEIBEENPWNEDAPI = "https://haveibeenpwned.com/api/v2/breachedaccount/%s"
|
URL_HAVEIBEENPWNEDAPI = "https://haveibeenpwned.com/api/v2/breachedaccount/%s"
|
||||||
URL_HAVEIBEENPWNED = "https://haveibeenpwned.com/"
|
URL_HAVEIBEENPWNED = "https://haveibeenpwned.com/"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#--require-config omdbapi-api-key
|
#--require-config omdbapi-api-key
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_OMDB = "http://www.omdbapi.com/"
|
URL_OMDB = "http://www.omdbapi.com/"
|
||||||
URL_IMDBTITLE = "http://imdb.com/title/%s"
|
URL_IMDBTITLE = "http://imdb.com/title/%s"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
SECONDS_MAX = Utils.SECONDS_WEEKS*8
|
SECONDS_MAX = Utils.SECONDS_WEEKS*8
|
||||||
SECONDS_MAX_DESCRIPTION = "8 weeks"
|
SECONDS_MAX_DESCRIPTION = "8 weeks"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import re
|
import re
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
ISGD_API_URL = "https://is.gd/create.php"
|
ISGD_API_URL = "https://is.gd/create.php"
|
||||||
REGEX_URL = re.compile("https?://", re.I)
|
REGEX_URL = re.compile("https?://", re.I)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import re, time
|
import re, time
|
||||||
import EventManager, Utils
|
from src import EventManager, Utils
|
||||||
|
|
||||||
REGEX_KARMA = re.compile("^(.*[^-+])[-+]*(\+{2,}|\-{2,})$")
|
REGEX_KARMA = re.compile("^(.*[^-+])[-+]*(\+{2,}|\-{2,})$")
|
||||||
KARMA_DELAY_SECONDS = 3
|
KARMA_DELAY_SECONDS = 3
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#--require-config lastfm-api-key
|
#--require-config lastfm-api-key
|
||||||
|
|
||||||
import Utils
|
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
from src import Utils
|
||||||
|
|
||||||
URL_SCROBBLER = "http://ws.audioscrobbler.com/2.0/"
|
URL_SCROBBLER = "http://ws.audioscrobbler.com/2.0/"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import ModuleManager
|
from src import ModuleManager
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import base64
|
import base64
|
||||||
import EventManager
|
from src import EventManager
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
|
|
@ -2,7 +2,7 @@ import collections, re, time
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
from suds.client import Client
|
from suds.client import Client
|
||||||
from suds import WebFault
|
from suds import WebFault
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import EventManager
|
from src import EventManager
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import ModuleManager, Utils
|
from src import ModuleManager, Utils
|
||||||
|
|
||||||
class Module(ModuleManager.BaseModule):
|
class Module(ModuleManager.BaseModule):
|
||||||
@Utils.hook("received.command.ping", help="Ping pong!")
|
@Utils.hook("received.command.ping", help="Ping pong!")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import datetime
|
import datetime
|
||||||
import EventManager
|
from src import EventManager
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import re, traceback
|
import re, traceback
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
REGEX_SPLIT = re.compile("(?<!\\\\)/")
|
REGEX_SPLIT = re.compile("(?<!\\\\)/")
|
||||||
REGEX_SED = re.compile("^s/")
|
REGEX_SED = re.compile("^s/")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import random
|
import random
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
INSULT_INTRO = ["Thou art a", "Ye", "Thou", "Thy", "Thee"]
|
INSULT_INTRO = ["Thou art a", "Ye", "Thou", "Thy", "Thee"]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import signal
|
import signal
|
||||||
import Config
|
from src import Config
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#--require-config soundcloud-api-key
|
#--require-config soundcloud-api-key
|
||||||
|
|
||||||
import json, re, time
|
import json, re, time
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_SOUNDCLOUD_TRACK = "http://api.soundcloud.com/tracks"
|
URL_SOUNDCLOUD_TRACK = "http://api.soundcloud.com/tracks"
|
||||||
URL_SOUNDCLOUD_RESOLVE = "http://api.soundcloud.com/resolve"
|
URL_SOUNDCLOUD_RESOLVE = "http://api.soundcloud.com/resolve"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import json
|
import json
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_SPOTIFY = "https://api.spotify.com/v1/search"
|
URL_SPOTIFY = "https://api.spotify.com/v1/search"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import collections, datetime, re
|
import collections, datetime, re
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_BUS = "https://api.tfl.gov.uk/StopPoint/%s/Arrivals"
|
URL_BUS = "https://api.tfl.gov.uk/StopPoint/%s/Arrivals"
|
||||||
URL_BUS_SEARCH = "https://api.tfl.gov.uk/StopPoint/Search/%s"
|
URL_BUS_SEARCH = "https://api.tfl.gov.uk/StopPoint/Search/%s"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#--require-config bighugethesaurus-api-key
|
#--require-config bighugethesaurus-api-key
|
||||||
|
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_THESAURUS = "http://words.bighugelabs.com/api/2/%s/%s/json"
|
URL_THESAURUS = "http://words.bighugelabs.com/api/2/%s/%s/json"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import re
|
import re
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
REGEX_URL = re.compile("https?://\S+", re.I)
|
REGEX_URL = re.compile("https?://\S+", re.I)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import EventManager
|
from src import EventManager
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#--require-config trakt-api-key
|
#--require-config trakt-api-key
|
||||||
|
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_TRAKT = "https://api-v2launch.trakt.tv/users/%s/watching"
|
URL_TRAKT = "https://api-v2launch.trakt.tv/users/%s/watching"
|
||||||
URL_TRAKTSLUG = "https://trakt.tv/%s/%s"
|
URL_TRAKTSLUG = "https://trakt.tv/%s/%s"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import json, re
|
import json, re
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_TRANSLATE = "http://translate.googleapis.com/translate_a/single"
|
URL_TRANSLATE = "http://translate.googleapis.com/translate_a/single"
|
||||||
URL_LANGUAGES = "https://cloud.google.com/translate/docs/languages"
|
URL_LANGUAGES = "https://cloud.google.com/translate/docs/languages"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
import datetime, re, time, traceback
|
import datetime, re, time, traceback
|
||||||
import twitter
|
import twitter
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
REGEX_TWITTERURL = re.compile(
|
REGEX_TWITTERURL = re.compile(
|
||||||
"https?://(?:www\.)?twitter.com/[^/]+/status/(\d+)", re.I)
|
"https?://(?:www\.)?twitter.com/[^/]+/status/(\d+)", re.I)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
UPCITEMDB_URL = "https://api.upcitemdb.com/prod/trial/lookup"
|
UPCITEMDB_URL = "https://api.upcitemdb.com/prod/trial/lookup"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import json, re
|
import json, re
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_URBANDICTIONARY = "http://api.urbandictionary.com/v0/define"
|
URL_URBANDICTIONARY = "http://api.urbandictionary.com/v0/define"
|
||||||
REGEX_DEFNUMBER = re.compile("-n(\d+) \S+")
|
REGEX_DEFNUMBER = re.compile("-n(\d+) \S+")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#--require-config openweathermap-api-key
|
#--require-config openweathermap-api-key
|
||||||
|
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_WEATHER = "http://api.openweathermap.org/data/2.5/weather"
|
URL_WEATHER = "http://api.openweathermap.org/data/2.5/weather"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_WIKIPEDIA = "https://en.wikipedia.org/w/api.php"
|
URL_WIKIPEDIA = "https://en.wikipedia.org/w/api.php"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#--require-config wolframalpha-api-key
|
#--require-config wolframalpha-api-key
|
||||||
import json
|
import json
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
URL_WA = "https://api.wolframalpha.com/v1/result"
|
URL_WA = "https://api.wolframalpha.com/v1/result"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import time
|
import time
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#--require-config google-api-key
|
#--require-config google-api-key
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import Utils
|
from src import Utils
|
||||||
|
|
||||||
REGEX_YOUTUBE = re.compile(
|
REGEX_YOUTUBE = re.compile(
|
||||||
"https?://(?:www.)?(?:youtu.be/|youtube.com/watch\?[\S]*v=)([\w\-]{11})",
|
"https?://(?:www.)?(?:youtu.be/|youtube.com/watch\?[\S]*v=)([\w\-]{11})",
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import configparser, os
|
import configparser, os
|
||||||
|
|
||||||
class Config(object):
|
class Config(object):
|
||||||
def __init__(self, bot, location="bot.conf"):
|
def __init__(self, bot, directory, filename="bot.conf"):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.location = location
|
self.filename = filename
|
||||||
self.full_location = os.path.join(bot.bot_directory,
|
self.full_location = os.path.join(directory, filename)
|
||||||
self.location)
|
|
||||||
self.bot.config = {}
|
self.bot.config = {}
|
||||||
self.load_config()
|
self.load_config()
|
||||||
|
|
|
@ -239,11 +239,10 @@ class UserChannelSettings(Table):
|
||||||
[user_id, channel_id, setting.lower()])
|
[user_id, channel_id, setting.lower()])
|
||||||
|
|
||||||
class Database(object):
|
class Database(object):
|
||||||
def __init__(self, bot, location="bot.db"):
|
def __init__(self, bot, directory, filename="bot.db"):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.location = location
|
self.filename = filename
|
||||||
self.full_location = os.path.join(bot.bot_directory,
|
self.full_location = os.path.join(directory, filename)
|
||||||
self.location)
|
|
||||||
self.database = sqlite3.connect(self.full_location,
|
self.database = sqlite3.connect(self.full_location,
|
||||||
check_same_thread=False, isolation_level=None)
|
check_same_thread=False, isolation_level=None)
|
||||||
self.database.execute("PRAGMA foreign_keys = ON")
|
self.database.execute("PRAGMA foreign_keys = ON")
|
|
@ -1,7 +1,6 @@
|
||||||
import os, select, sys, threading, time, traceback, uuid
|
import os, select, sys, threading, time, traceback, uuid
|
||||||
|
from . import EventManager, Exports, IRCLineHandler, IRCServer, Logging
|
||||||
import EventManager, Exports, IRCLineHandler, IRCServer, Logging
|
from . import ModuleManager, Timer
|
||||||
import ModuleManager, Timer
|
|
||||||
|
|
||||||
class Bot(object):
|
class Bot(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -14,15 +13,13 @@ class Bot(object):
|
||||||
self.servers = {}
|
self.servers = {}
|
||||||
self.running = True
|
self.running = True
|
||||||
self.poll = select.epoll()
|
self.poll = select.epoll()
|
||||||
self._events = EventManager.EventHook(self)
|
|
||||||
self._exports = Exports.Exports()
|
|
||||||
self.modules = ModuleManager.ModuleManager(self, self._events,
|
|
||||||
self._exports)
|
|
||||||
self.log = Logging.Log(self)
|
|
||||||
self.line_handler = IRCLineHandler.LineHandler(self, self._events)
|
|
||||||
self.timers = []
|
self.timers = []
|
||||||
self._events.on("timer.reconnect").hook(self.reconnect)
|
|
||||||
self._events.on("boot.done").hook(self.setup_timers)
|
self._events = None
|
||||||
|
self._exports = None
|
||||||
|
self.modules = None
|
||||||
|
self.log = None
|
||||||
|
self.line_handler = None
|
||||||
|
|
||||||
def add_server(self, server_id, connect=True):
|
def add_server(self, server_id, connect=True):
|
||||||
(_, alias, hostname, port, password, ipv4, tls, nickname,
|
(_, alias, hostname, port, password, ipv4, tls, nickname,
|
|
@ -1,5 +1,5 @@
|
||||||
import re
|
import re
|
||||||
import Utils
|
from . import Utils
|
||||||
|
|
||||||
class BufferLine(object):
|
class BufferLine(object):
|
||||||
def __init__(self, sender, message, action, from_self):
|
def __init__(self, sender, message, action, from_self):
|
|
@ -1,5 +1,5 @@
|
||||||
import uuid
|
import uuid
|
||||||
import IRCBuffer, Utils
|
from . import IRCBuffer, Utils
|
||||||
|
|
||||||
class Channel(object):
|
class Channel(object):
|
||||||
def __init__(self, name, id, server, bot):
|
def __init__(self, name, id, server, bot):
|
|
@ -1,5 +1,5 @@
|
||||||
import re, threading
|
import re, threading
|
||||||
import Utils
|
from . import Utils
|
||||||
|
|
||||||
RE_PREFIXES = re.compile(r"\bPREFIX=\((\w+)\)(\W+)(?:\b|$)")
|
RE_PREFIXES = re.compile(r"\bPREFIX=\((\w+)\)(\W+)(?:\b|$)")
|
||||||
RE_CHANMODES = re.compile(
|
RE_CHANMODES = re.compile(
|
|
@ -1,5 +1,5 @@
|
||||||
import collections, socket, ssl, sys, time
|
import collections, socket, ssl, sys, time
|
||||||
import IRCChannel, IRCUser, Utils
|
from . import IRCChannel, IRCUser, Utils
|
||||||
|
|
||||||
THROTTLE_LINES = 4
|
THROTTLE_LINES = 4
|
||||||
THROTTLE_SECONDS = 1
|
THROTTLE_SECONDS = 1
|
|
@ -1,5 +1,5 @@
|
||||||
import uuid
|
import uuid
|
||||||
import IRCBuffer, Utils
|
from . import IRCBuffer, Utils
|
||||||
|
|
||||||
class User(object):
|
class User(object):
|
||||||
def __init__(self, nickname, id, server, bot):
|
def __init__(self, nickname, id, server, bot):
|
|
@ -1,4 +1,4 @@
|
||||||
import logging, logging.handlers, sys, time
|
import logging, logging.handlers, os, sys, time
|
||||||
|
|
||||||
class BitBotFormatter(logging.Formatter):
|
class BitBotFormatter(logging.Formatter):
|
||||||
def formatTime(self, record, datefmt=None):
|
def formatTime(self, record, datefmt=None):
|
||||||
|
@ -14,7 +14,7 @@ class BitBotFormatter(logging.Formatter):
|
||||||
return s
|
return s
|
||||||
|
|
||||||
class Log(object):
|
class Log(object):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot, directory, filename):
|
||||||
self.logger = logging.getLogger(__name__)
|
self.logger = logging.getLogger(__name__)
|
||||||
self.logger.setLevel(logging.DEBUG)
|
self.logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class Log(object):
|
||||||
self.logger.addHandler(stdout_handler)
|
self.logger.addHandler(stdout_handler)
|
||||||
|
|
||||||
file_handler = logging.handlers.TimedRotatingFileHandler(
|
file_handler = logging.handlers.TimedRotatingFileHandler(
|
||||||
"bot.log", when="midnight", backupCount=5)
|
os.path.join(directory, filename), when="midnight", backupCount=5)
|
||||||
file_handler.setLevel(logging.DEBUG)
|
file_handler.setLevel(logging.DEBUG)
|
||||||
file_handler.setFormatter(formatter)
|
file_handler.setFormatter(formatter)
|
||||||
self.logger.addHandler(file_handler)
|
self.logger.addHandler(file_handler)
|
|
@ -24,7 +24,7 @@ class BaseModule(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class ModuleManager(object):
|
class ModuleManager(object):
|
||||||
def __init__(self, bot, events, exports, directory="modules"):
|
def __init__(self, bot, events, exports, directory):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.events = events
|
self.events = events
|
||||||
self.exports = exports
|
self.exports = exports
|
||||||
|
@ -109,7 +109,7 @@ class ModuleManager(object):
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.bot.log.error("Failed to load module \"%s\": %s",
|
self.bot.log.error("Failed to load module \"%s\": %s",
|
||||||
[name, e.msg])
|
[name, str(e)])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
self.modules[module._import_name] = module
|
self.modules[module._import_name] = module
|
|
@ -1,7 +1,7 @@
|
||||||
import json, re, traceback, urllib.request, urllib.parse, urllib.error, ssl
|
import json, re, traceback, urllib.request, urllib.parse, urllib.error, ssl
|
||||||
import string
|
import string
|
||||||
import bs4
|
import bs4
|
||||||
import ModuleManager
|
from . import ModuleManager
|
||||||
|
|
||||||
USER_AGENT = ("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 "
|
USER_AGENT = ("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 "
|
||||||
"(KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36")
|
"(KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36")
|
28
start.py
28
start.py
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import argparse, sys, time
|
import argparse, os, sys, time
|
||||||
import IRCBot, Config, Database
|
from src import Config, Database, EventManager, Exports, IRCBot
|
||||||
|
from src import IRCLineHandler, Logging, ModuleManager
|
||||||
|
|
||||||
def bool_input(s):
|
def bool_input(s):
|
||||||
result = input("%s (Y/n): " % s)
|
result = input("%s (Y/n): " % s)
|
||||||
|
@ -17,20 +18,29 @@ arg_parser.add_argument("--verbose", "-v", action="store_true")
|
||||||
|
|
||||||
args = arg_parser.parse_args()
|
args = arg_parser.parse_args()
|
||||||
|
|
||||||
bot = IRCBot.Bot()
|
directory = os.path.dirname(os.path.realpath(__file__))
|
||||||
database = Database.Database(bot, args.database)
|
|
||||||
config = Config.Config(bot, args.config)
|
|
||||||
|
|
||||||
bot.database = database
|
bot = IRCBot.Bot()
|
||||||
bot.config = config.load_config()
|
|
||||||
|
bot._events = events = EventManager.EventHook(bot)
|
||||||
|
bot._exports = exports = Exports.Exports()
|
||||||
|
bot.modules = modules = ModuleManager.ModuleManager(bot, events, exports,
|
||||||
|
os.path.join(directory, "modules"))
|
||||||
|
bot.line_handler = IRCLineHandler.LineHandler(bot, bot._events)
|
||||||
|
bot.log = Logging.Log(bot, directory, "bot.log")
|
||||||
|
bot.database = Database.Database(bot, directory, args.database)
|
||||||
|
bot.config = Config.Config(bot, directory, args.config).load_config()
|
||||||
bot.args = args
|
bot.args = args
|
||||||
|
|
||||||
|
bot._events.on("timer.reconnect").hook(bot.reconnect)
|
||||||
|
bot._events.on("boot.done").hook(bot.setup_timers)
|
||||||
|
|
||||||
whitelist = bot.get_setting("module-whitelist", [])
|
whitelist = bot.get_setting("module-whitelist", [])
|
||||||
blacklist = bot.get_setting("module-blacklist", [])
|
blacklist = bot.get_setting("module-blacklist", [])
|
||||||
bot.modules.load_modules(whitelist=whitelist, blacklist=blacklist)
|
bot.modules.load_modules(whitelist=whitelist, blacklist=blacklist)
|
||||||
|
|
||||||
servers = []
|
servers = []
|
||||||
for server_id, alias in database.servers.get_all():
|
for server_id, alias in bot.database.servers.get_all():
|
||||||
server = bot.add_server(server_id, connect=False)
|
server = bot.add_server(server_id, connect=False)
|
||||||
if not server == None:
|
if not server == None:
|
||||||
servers.append(server)
|
servers.append(server)
|
||||||
|
@ -54,7 +64,7 @@ else:
|
||||||
nickname = input("nickname: ")
|
nickname = input("nickname: ")
|
||||||
username = input("username: ")
|
username = input("username: ")
|
||||||
realname = input("realname: ")
|
realname = input("realname: ")
|
||||||
database.servers.add(alias, hostname, port, password, ipv4,
|
bot.database.servers.add(alias, hostname, port, password, ipv4,
|
||||||
tls, nickname, username, realname)
|
tls, nickname, username, realname)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print()
|
print()
|
||||||
|
|
Loading…
Reference in a new issue