Moved @irc3.plugin into bot.plugins.BasePlugin -> saved some lines
This commit is contained in:
parent
1939635cdb
commit
7f5571fc09
4
bot/__init__.py
Normal file
4
bot/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import os
|
||||||
|
|
||||||
|
REPO_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
@ -1,12 +1,13 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from irc3 import IrcBot
|
import irc3
|
||||||
from irc3.plugins.command import Commands
|
from irc3.plugins.command import Commands
|
||||||
|
|
||||||
MODULE = __name__
|
MODULE = __name__
|
||||||
|
|
||||||
|
|
||||||
|
@irc3.plugin
|
||||||
class BasePlugin(object):
|
class BasePlugin(object):
|
||||||
def __init__(self, bot: IrcBot):
|
def __init__(self, bot: irc3.IrcBot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.log = bot.log
|
self.log = bot.log
|
||||||
self.guard = bot.get_plugin(Commands).guard
|
self.guard = bot.get_plugin(Commands).guard
|
||||||
|
@ -23,7 +24,7 @@ from .storage import Storage # noqa
|
||||||
|
|
||||||
|
|
||||||
class DatabasePlugin(Plugin):
|
class DatabasePlugin(Plugin):
|
||||||
def __init__(self, bot: IrcBot):
|
def __init__(self, bot: irc3.IrcBot):
|
||||||
super().__init__(bot)
|
super().__init__(bot)
|
||||||
# Get PgSQL storage instance and connection + cursor
|
# Get PgSQL storage instance and connection + cursor
|
||||||
self.db = bot.get_plugin(Storage)
|
self.db = bot.get_plugin(Storage)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import irc3
|
|
||||||
import requests
|
import requests
|
||||||
from docopt import Dict
|
from docopt import Dict
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
|
@ -8,7 +7,6 @@ from irc3.utils import IrcString
|
||||||
from . import Plugin
|
from . import Plugin
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class Coins(Plugin):
|
class Coins(Plugin):
|
||||||
requires = ['irc3.plugins.command']
|
requires = ['irc3.plugins.command']
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import irc3
|
|
||||||
from docopt import Dict
|
from docopt import Dict
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from irc3.utils import IrcString
|
from irc3.utils import IrcString
|
||||||
|
@ -9,7 +8,6 @@ from irc3.utils import IrcString
|
||||||
from . import Plugin
|
from . import Plugin
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class CTCP(Plugin):
|
class CTCP(Plugin):
|
||||||
requires = ['irc3.plugins.async',
|
requires = ['irc3.plugins.async',
|
||||||
'irc3.plugins.command']
|
'irc3.plugins.command']
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import irc3
|
|
||||||
import requests
|
import requests
|
||||||
from docopt import Dict
|
from docopt import Dict
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
|
@ -10,7 +9,6 @@ from irc3.utils import IrcString
|
||||||
from . import DatabasePlugin
|
from . import DatabasePlugin
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class Useless(DatabasePlugin):
|
class Useless(DatabasePlugin):
|
||||||
requires = ['irc3.plugins.command',
|
requires = ['irc3.plugins.command',
|
||||||
'bot.plugins.storage']
|
'bot.plugins.storage']
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import irc3
|
import irc3
|
||||||
|
|
||||||
from docopt import Dict
|
from docopt import Dict
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from irc3.utils import IrcString
|
from irc3.utils import IrcString
|
||||||
|
@ -10,7 +9,6 @@ from . import DatabasePlugin
|
||||||
from ..utils import parse_int
|
from ..utils import parse_int
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class McManiac(DatabasePlugin):
|
class McManiac(DatabasePlugin):
|
||||||
requires = ['irc3.plugins.command',
|
requires = ['irc3.plugins.command',
|
||||||
'bot.plugins.storage']
|
'bot.plugins.storage']
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import irc3
|
|
||||||
from docopt import Dict
|
from docopt import Dict
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from irc3.utils import IrcString
|
from irc3.utils import IrcString
|
||||||
|
@ -11,7 +10,6 @@ from . import DatabasePlugin
|
||||||
from ..utils import parse_int
|
from ..utils import parse_int
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class Quotes(DatabasePlugin):
|
class Quotes(DatabasePlugin):
|
||||||
requires = ['irc3.plugins.command',
|
requires = ['irc3.plugins.command',
|
||||||
'bot.plugins.storage']
|
'bot.plugins.storage']
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import random
|
import random
|
||||||
|
|
||||||
import irc3
|
|
||||||
from docopt import Dict
|
from docopt import Dict
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
from irc3.utils import IrcString
|
from irc3.utils import IrcString
|
||||||
|
@ -9,7 +8,6 @@ from irc3.utils import IrcString
|
||||||
from . import DatabasePlugin
|
from . import DatabasePlugin
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class Rape(DatabasePlugin):
|
class Rape(DatabasePlugin):
|
||||||
requires = ['irc3.plugins.command',
|
requires = ['irc3.plugins.command',
|
||||||
'bot.plugins.storage']
|
'bot.plugins.storage']
|
||||||
|
|
|
@ -7,7 +7,6 @@ from irc3.utils import IrcString
|
||||||
from . import DatabasePlugin
|
from . import DatabasePlugin
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class Useless(DatabasePlugin):
|
class Useless(DatabasePlugin):
|
||||||
requires = ['irc3.plugins.command',
|
requires = ['irc3.plugins.command',
|
||||||
'bot.plugins.storage']
|
'bot.plugins.storage']
|
||||||
|
|
|
@ -9,7 +9,6 @@ from irc3.utils import IrcString
|
||||||
from . import DatabasePlugin
|
from . import DatabasePlugin
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class Seen(DatabasePlugin):
|
class Seen(DatabasePlugin):
|
||||||
requires = ['irc3.plugins.command',
|
requires = ['irc3.plugins.command',
|
||||||
'bot.plugins.storage']
|
'bot.plugins.storage']
|
||||||
|
|
|
@ -8,7 +8,6 @@ from psycopg2.extras import DictCursor
|
||||||
from . import Plugin
|
from . import Plugin
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class Storage(Plugin):
|
class Storage(Plugin):
|
||||||
def __init__(self, bot: irc3.IrcBot):
|
def __init__(self, bot: irc3.IrcBot):
|
||||||
super().__init__(bot)
|
super().__init__(bot)
|
||||||
|
|
|
@ -10,7 +10,6 @@ from psycopg2 import Error
|
||||||
from . import DatabasePlugin
|
from . import DatabasePlugin
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class Tell(DatabasePlugin):
|
class Tell(DatabasePlugin):
|
||||||
requires = ['irc3.plugins.command',
|
requires = ['irc3.plugins.command',
|
||||||
'bot.plugins.storage']
|
'bot.plugins.storage']
|
||||||
|
|
|
@ -14,7 +14,6 @@ from psycopg2.extras import DictRow
|
||||||
from . import DatabasePlugin
|
from . import DatabasePlugin
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class Timer(DatabasePlugin):
|
class Timer(DatabasePlugin):
|
||||||
requires = ['irc3.plugins.command',
|
requires = ['irc3.plugins.command',
|
||||||
'bot.plugins.storage']
|
'bot.plugins.storage']
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import irc3
|
|
||||||
import requests
|
import requests
|
||||||
from docopt import Dict
|
from docopt import Dict
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
|
@ -8,7 +7,6 @@ from irc3.utils import IrcString
|
||||||
from . import Plugin
|
from . import Plugin
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class Urban(Plugin):
|
class Urban(Plugin):
|
||||||
requires = ['irc3.plugins.command']
|
requires = ['irc3.plugins.command']
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,19 @@ from psycopg2 import Error
|
||||||
from . import DatabasePlugin
|
from . import DatabasePlugin
|
||||||
from ..utils import re_generator
|
from ..utils import re_generator
|
||||||
|
|
||||||
|
|
||||||
|
class Useless(DatabasePlugin):
|
||||||
|
requires = ['irc3.plugins.command',
|
||||||
|
'bot.plugins.storage']
|
||||||
|
|
||||||
RAINBOW = (5, 7, 8, 9, 3, 10, 12, 2, 6, 13)
|
RAINBOW = (5, 7, 8, 9, 3, 10, 12, 2, 6, 13)
|
||||||
RAINBOW_LEN = len(RAINBOW)
|
|
||||||
|
WOAH = (
|
||||||
|
'woah',
|
||||||
|
'woah indeed',
|
||||||
|
'woah woah woah!',
|
||||||
|
'keep your woahs to yourself',
|
||||||
|
)
|
||||||
|
|
||||||
ISPS = (
|
ISPS = (
|
||||||
't-ipconnect',
|
't-ipconnect',
|
||||||
|
@ -29,18 +40,6 @@ GENDERS = (
|
||||||
'hermaphrodite',
|
'hermaphrodite',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class Useless(DatabasePlugin):
|
|
||||||
requires = ['irc3.plugins.command',
|
|
||||||
'bot.plugins.storage']
|
|
||||||
WOAH = (
|
|
||||||
'woah',
|
|
||||||
'woah indeed',
|
|
||||||
'woah woah woah!',
|
|
||||||
'keep your woahs to yourself',
|
|
||||||
)
|
|
||||||
|
|
||||||
@command(permission='admin', show_in_help=False)
|
@command(permission='admin', show_in_help=False)
|
||||||
def kim(self, mask: IrcString, target: IrcString, args: Dict):
|
def kim(self, mask: IrcString, target: IrcString, args: Dict):
|
||||||
"""Kicks Kim, most useful command.
|
"""Kicks Kim, most useful command.
|
||||||
|
@ -49,7 +48,7 @@ class Useless(DatabasePlugin):
|
||||||
"""
|
"""
|
||||||
self.bot.kick(target, 'Kim')
|
self.bot.kick(target, 'Kim')
|
||||||
|
|
||||||
@irc3.event(r'(?i)^:(?P<mask>\S+@\S+({isps})\S+) JOIN :(?P<target>#\S+)$'.format(isps='|'.join(ISPS)))
|
@irc3.event(r'(?i)^:(?P<mask>\S+@\S+({})\S+) JOIN :(?P<target>#\S+)$'.format('|'.join(ISPS)))
|
||||||
def bounce(self, mask, target):
|
def bounce(self, mask, target):
|
||||||
nick = IrcString(mask).nick
|
nick = IrcString(mask).nick
|
||||||
|
|
||||||
|
@ -286,7 +285,7 @@ class Useless(DatabasePlugin):
|
||||||
%%assume [<nick>]
|
%%assume [<nick>]
|
||||||
"""
|
"""
|
||||||
nick = args.get('<nick>', mask.nick)
|
nick = args.get('<nick>', mask.nick)
|
||||||
gender = random.choice(GENDERS)
|
gender = random.choice(self.GENDERS)
|
||||||
|
|
||||||
return 'Assuming {}\'s gender... they\'re a {}.'.format(nick, gender)
|
return 'Assuming {}\'s gender... they\'re a {}.'.format(nick, gender)
|
||||||
|
|
||||||
|
@ -338,4 +337,4 @@ class Useless(DatabasePlugin):
|
||||||
|
|
||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
def _rainbow(self, i, char):
|
def _rainbow(self, i, char):
|
||||||
return '\x03{0:02d}{1}'.format(RAINBOW[i % RAINBOW_LEN], char)
|
return '\x03{0:02d}{1}'.format(self.RAINBOW[i % len(self.RAINBOW)], char)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import irc3
|
|
||||||
import requests
|
import requests
|
||||||
from docopt import Dict
|
from docopt import Dict
|
||||||
from irc3.plugins.command import command
|
from irc3.plugins.command import command
|
||||||
|
@ -8,7 +7,6 @@ from irc3.utils import IrcString
|
||||||
from . import Plugin
|
from . import Plugin
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class Weather(Plugin):
|
class Weather(Plugin):
|
||||||
requires = ['irc3.plugins.command']
|
requires = ['irc3.plugins.command']
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ from . import Plugin
|
||||||
from ..utils import date_from_iso
|
from ..utils import date_from_iso
|
||||||
|
|
||||||
|
|
||||||
@irc3.plugin
|
|
||||||
class YouTube(Plugin):
|
class YouTube(Plugin):
|
||||||
requires = ['irc3.plugins.command']
|
requires = ['irc3.plugins.command']
|
||||||
|
|
||||||
|
|
|
@ -4,5 +4,6 @@ git+https://github.com/mrhanky17/docopt.git#egg=docopt
|
||||||
aiocron==0.6
|
aiocron==0.6
|
||||||
psycopg2==2.7.1
|
psycopg2==2.7.1
|
||||||
requests==2.14.2
|
requests==2.14.2
|
||||||
|
GitPython==2.1.5
|
||||||
feedparser==5.2.1
|
feedparser==5.2.1
|
||||||
python_dotenv==0.6.4
|
python_dotenv==0.6.4
|
||||||
|
|
Loading…
Reference in New Issue
Block a user