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 -*-
|
||||
from irc3 import IrcBot
|
||||
import irc3
|
||||
from irc3.plugins.command import Commands
|
||||
|
||||
MODULE = __name__
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class BasePlugin(object):
|
||||
def __init__(self, bot: IrcBot):
|
||||
def __init__(self, bot: irc3.IrcBot):
|
||||
self.bot = bot
|
||||
self.log = bot.log
|
||||
self.guard = bot.get_plugin(Commands).guard
|
||||
|
@ -23,7 +24,7 @@ from .storage import Storage # noqa
|
|||
|
||||
|
||||
class DatabasePlugin(Plugin):
|
||||
def __init__(self, bot: IrcBot):
|
||||
def __init__(self, bot: irc3.IrcBot):
|
||||
super().__init__(bot)
|
||||
# Get PgSQL storage instance and connection + cursor
|
||||
self.db = bot.get_plugin(Storage)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import irc3
|
||||
import requests
|
||||
from docopt import Dict
|
||||
from irc3.plugins.command import command
|
||||
|
@ -8,7 +7,6 @@ from irc3.utils import IrcString
|
|||
from . import Plugin
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class Coins(Plugin):
|
||||
requires = ['irc3.plugins.command']
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import time
|
||||
|
||||
import irc3
|
||||
from docopt import Dict
|
||||
from irc3.plugins.command import command
|
||||
from irc3.utils import IrcString
|
||||
|
@ -9,7 +8,6 @@ from irc3.utils import IrcString
|
|||
from . import Plugin
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class CTCP(Plugin):
|
||||
requires = ['irc3.plugins.async',
|
||||
'irc3.plugins.command']
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import irc3
|
||||
import requests
|
||||
from docopt import Dict
|
||||
from irc3.plugins.command import command
|
||||
|
@ -10,7 +9,6 @@ from irc3.utils import IrcString
|
|||
from . import DatabasePlugin
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class Useless(DatabasePlugin):
|
||||
requires = ['irc3.plugins.command',
|
||||
'bot.plugins.storage']
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import irc3
|
||||
|
||||
from docopt import Dict
|
||||
from irc3.plugins.command import command
|
||||
from irc3.utils import IrcString
|
||||
|
@ -10,7 +9,6 @@ from . import DatabasePlugin
|
|||
from ..utils import parse_int
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class McManiac(DatabasePlugin):
|
||||
requires = ['irc3.plugins.command',
|
||||
'bot.plugins.storage']
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
|
||||
import irc3
|
||||
from docopt import Dict
|
||||
from irc3.plugins.command import command
|
||||
from irc3.utils import IrcString
|
||||
|
@ -11,7 +10,6 @@ from . import DatabasePlugin
|
|||
from ..utils import parse_int
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class Quotes(DatabasePlugin):
|
||||
requires = ['irc3.plugins.command',
|
||||
'bot.plugins.storage']
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import random
|
||||
|
||||
import irc3
|
||||
from docopt import Dict
|
||||
from irc3.plugins.command import command
|
||||
from irc3.utils import IrcString
|
||||
|
@ -9,7 +8,6 @@ from irc3.utils import IrcString
|
|||
from . import DatabasePlugin
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class Rape(DatabasePlugin):
|
||||
requires = ['irc3.plugins.command',
|
||||
'bot.plugins.storage']
|
||||
|
|
|
@ -7,7 +7,6 @@ from irc3.utils import IrcString
|
|||
from . import DatabasePlugin
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class Useless(DatabasePlugin):
|
||||
requires = ['irc3.plugins.command',
|
||||
'bot.plugins.storage']
|
||||
|
|
|
@ -9,7 +9,6 @@ from irc3.utils import IrcString
|
|||
from . import DatabasePlugin
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class Seen(DatabasePlugin):
|
||||
requires = ['irc3.plugins.command',
|
||||
'bot.plugins.storage']
|
||||
|
|
|
@ -8,7 +8,6 @@ from psycopg2.extras import DictCursor
|
|||
from . import Plugin
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class Storage(Plugin):
|
||||
def __init__(self, bot: irc3.IrcBot):
|
||||
super().__init__(bot)
|
||||
|
|
|
@ -10,7 +10,6 @@ from psycopg2 import Error
|
|||
from . import DatabasePlugin
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class Tell(DatabasePlugin):
|
||||
requires = ['irc3.plugins.command',
|
||||
'bot.plugins.storage']
|
||||
|
|
|
@ -14,7 +14,6 @@ from psycopg2.extras import DictRow
|
|||
from . import DatabasePlugin
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class Timer(DatabasePlugin):
|
||||
requires = ['irc3.plugins.command',
|
||||
'bot.plugins.storage']
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import irc3
|
||||
import requests
|
||||
from docopt import Dict
|
||||
from irc3.plugins.command import command
|
||||
|
@ -8,7 +7,6 @@ from irc3.utils import IrcString
|
|||
from . import Plugin
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class Urban(Plugin):
|
||||
requires = ['irc3.plugins.command']
|
||||
|
||||
|
|
|
@ -11,29 +11,13 @@ from psycopg2 import Error
|
|||
from . import DatabasePlugin
|
||||
from ..utils import re_generator
|
||||
|
||||
RAINBOW = (5, 7, 8, 9, 3, 10, 12, 2, 6, 13)
|
||||
RAINBOW_LEN = len(RAINBOW)
|
||||
|
||||
ISPS = (
|
||||
't-ipconnect',
|
||||
'telefonica',
|
||||
'vodafone',
|
||||
'kabel',
|
||||
'unity-media',
|
||||
)
|
||||
|
||||
GENDERS = (
|
||||
'male',
|
||||
'female',
|
||||
'shemale',
|
||||
'hermaphrodite',
|
||||
)
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class Useless(DatabasePlugin):
|
||||
requires = ['irc3.plugins.command',
|
||||
'bot.plugins.storage']
|
||||
|
||||
RAINBOW = (5, 7, 8, 9, 3, 10, 12, 2, 6, 13)
|
||||
|
||||
WOAH = (
|
||||
'woah',
|
||||
'woah indeed',
|
||||
|
@ -41,6 +25,21 @@ class Useless(DatabasePlugin):
|
|||
'keep your woahs to yourself',
|
||||
)
|
||||
|
||||
ISPS = (
|
||||
't-ipconnect',
|
||||
'telefonica',
|
||||
'vodafone',
|
||||
'kabel',
|
||||
'unity-media',
|
||||
)
|
||||
|
||||
GENDERS = (
|
||||
'male',
|
||||
'female',
|
||||
'shemale',
|
||||
'hermaphrodite',
|
||||
)
|
||||
|
||||
@command(permission='admin', show_in_help=False)
|
||||
def kim(self, mask: IrcString, target: IrcString, args: Dict):
|
||||
"""Kicks Kim, most useful command.
|
||||
|
@ -49,7 +48,7 @@ class Useless(DatabasePlugin):
|
|||
"""
|
||||
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):
|
||||
nick = IrcString(mask).nick
|
||||
|
||||
|
@ -286,7 +285,7 @@ class Useless(DatabasePlugin):
|
|||
%%assume [<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)
|
||||
|
||||
|
@ -338,4 +337,4 @@ class Useless(DatabasePlugin):
|
|||
|
||||
# noinspection PyMethodMayBeStatic
|
||||
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 -*-
|
||||
import irc3
|
||||
import requests
|
||||
from docopt import Dict
|
||||
from irc3.plugins.command import command
|
||||
|
@ -8,7 +7,6 @@ from irc3.utils import IrcString
|
|||
from . import Plugin
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class Weather(Plugin):
|
||||
requires = ['irc3.plugins.command']
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ from . import Plugin
|
|||
from ..utils import date_from_iso
|
||||
|
||||
|
||||
@irc3.plugin
|
||||
class YouTube(Plugin):
|
||||
requires = ['irc3.plugins.command']
|
||||
|
||||
|
|
|
@ -4,5 +4,6 @@ git+https://github.com/mrhanky17/docopt.git#egg=docopt
|
|||
aiocron==0.6
|
||||
psycopg2==2.7.1
|
||||
requests==2.14.2
|
||||
GitPython==2.1.5
|
||||
feedparser==5.2.1
|
||||
python_dotenv==0.6.4
|
||||
|
|
Loading…
Reference in New Issue
Block a user