mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
kick and AI cleanup
This commit is contained in:
parent
83f62febc4
commit
dc93ca12a0
37
sopel_modules/SpiceBot/Kick.py
Normal file
37
sopel_modules/SpiceBot/Kick.py
Normal file
@ -0,0 +1,37 @@
|
||||
# coding=utf8
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
"""
|
||||
This is the SpiceBot Update system.
|
||||
"""
|
||||
|
||||
from sopel.config.types import StaticSection, ValidatedAttribute
|
||||
|
||||
|
||||
class SpiceBot_Kick(StaticSection):
|
||||
kick = ValidatedAttribute('kick', default=1)
|
||||
|
||||
|
||||
class SopelKICK:
|
||||
|
||||
def kick(self, nick, channel, text=None):
|
||||
"""Send an IRC KICK command.
|
||||
Within the context of a triggered callable, ``channel`` will default to the
|
||||
channel in which the call was triggered. If triggered from a private message,
|
||||
``channel`` is required (or the call to ``kick()`` will be ignored).
|
||||
The bot must be a channel operator in specified channel for this to work.
|
||||
.. versionadded:: 7.0
|
||||
"""
|
||||
self.write(['KICK', channel, nick], text)
|
||||
|
||||
|
||||
class SopelWrapperKICK(object):
|
||||
|
||||
def kick(self, nick, channel=None, message=None):
|
||||
if channel is None:
|
||||
if self._trigger.is_privmsg:
|
||||
raise RuntimeError('Error: KICK requires a channel.')
|
||||
else:
|
||||
channel = self._trigger.sender
|
||||
if nick is None:
|
||||
raise RuntimeError('Error: KICK requires a nick.')
|
||||
self._bot.kick(nick, channel, message)
|
||||
@ -11,6 +11,7 @@ from .setup import *
|
||||
|
||||
from .Update import *
|
||||
from .osd import *
|
||||
from .Kick import *
|
||||
|
||||
from .Config import *
|
||||
from .Tools import *
|
||||
|
||||
@ -4,6 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
|
||||
|
||||
from .Channels import SpiceBot_Channels_MainSection
|
||||
from .Update import SpiceBot_Update_MainSection
|
||||
from .Kick import SpiceBot_Kick
|
||||
from .osd import SpiceBot_OSD
|
||||
|
||||
|
||||
@ -27,3 +28,6 @@ def configure(config):
|
||||
config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False)
|
||||
config.SpiceBot_Update.configure_setting('gitrepo', 'SpiceBot_Update git repo to install')
|
||||
config.SpiceBot_Update.configure_setting('gitbranch', 'SpiceBot_Update git branch to install')
|
||||
|
||||
config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False)
|
||||
config.SpiceBot_Kick.configure_setting('kick', 'MAXTARG limit for KICK')
|
||||
|
||||
@ -14,6 +14,7 @@ from .Events import events
|
||||
from .Channels import SpiceBot_Channels_MainSection
|
||||
from .Update import SpiceBot_Update_MainSection
|
||||
from .osd import SopelWrapperOSD, ToolsOSD, SopelOSD, SpiceBot_OSD
|
||||
from .Kick import SopelWrapperKICK, SopelKICK, SpiceBot_Kick
|
||||
|
||||
|
||||
def setup(bot):
|
||||
@ -35,6 +36,16 @@ def setup(bot):
|
||||
bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False)
|
||||
botconfig.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False)
|
||||
|
||||
# Inject KICK
|
||||
logs.log('SpiceBot_Kick', "Implanting Kick function into bot")
|
||||
bot.kick = SopelKICK.kick
|
||||
sopel.bot.SopelWrapper.kick = SopelWrapperKICK.kick
|
||||
|
||||
# verify config settings for server
|
||||
logs.log('SpiceBot_Kick', "Checking for config settings")
|
||||
bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False)
|
||||
botconfig.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False)
|
||||
|
||||
logs.log('SpiceBot_Config', "Setting Up Configuration")
|
||||
bot.config.core.basename = os.path.basename(bot.config.filename).rsplit('.', 1)[0]
|
||||
bot.config.core.logs_stdio = os.path.join(bot.config.core.logdir, 'stdio.log')
|
||||
|
||||
@ -12,6 +12,7 @@ from .AI_Ping import *
|
||||
from .AI_Love import *
|
||||
from .AI_Really import *
|
||||
from .AI_Welcomeback import *
|
||||
from .AI_Gender import *
|
||||
|
||||
__author__ = 'Sam Zick'
|
||||
__email__ = 'sam@deathbybandaid.net'
|
||||
|
||||
@ -12,6 +12,8 @@ from .Database import *
|
||||
from .Uptime import *
|
||||
from .Logs import *
|
||||
from .Runtime_Controls import *
|
||||
from .Messaging import *
|
||||
from .Docs import *
|
||||
|
||||
__author__ = 'Sam Zick'
|
||||
__email__ = 'sam@deathbybandaid.net'
|
||||
|
||||
28
sopel_modules/SpiceBot_Core_Processing/Kick.py
Normal file
28
sopel_modules/SpiceBot_Core_Processing/Kick.py
Normal file
@ -0,0 +1,28 @@
|
||||
# coding=utf8
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
"""
|
||||
This is the SpiceBot OSD system.
|
||||
"""
|
||||
import sopel
|
||||
|
||||
|
||||
@sopel.module.event('005')
|
||||
@sopel.module.rule('.*')
|
||||
def parse_event_005(bot, trigger):
|
||||
if trigger.args[-1] != 'are supported by this server':
|
||||
return
|
||||
parameters = trigger.args[1:-1]
|
||||
for param in parameters:
|
||||
if '=' in param:
|
||||
if param.startswith("TARGMAX"):
|
||||
param = str(param).split('=')[1]
|
||||
settings = str(param).split(',')
|
||||
for setting in settings:
|
||||
settingname = str(setting).split(':')[0]
|
||||
if settingname.upper() in ['KICK']:
|
||||
try:
|
||||
value = str(setting).split(':')[1] or None
|
||||
except IndexError:
|
||||
value = None
|
||||
if value:
|
||||
bot.config.SpiceBot_Kick.kick = int(value)
|
||||
@ -12,6 +12,7 @@ from .Modules import *
|
||||
from .osd import *
|
||||
from .StartupMonologue import *
|
||||
from .Logs import *
|
||||
from .Kick import *
|
||||
|
||||
|
||||
__author__ = 'Sam Zick'
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
# coding=utf8
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
|
||||
from .Docs import *
|
||||
|
||||
__author__ = 'Sam Zick'
|
||||
__email__ = 'sam@deathbybandaid.net'
|
||||
__version__ = '0.1.1'
|
||||
@ -1,8 +0,0 @@
|
||||
# coding=utf8
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
|
||||
from .Gender import *
|
||||
|
||||
__author__ = 'Sam Zick'
|
||||
__email__ = 'sam@deathbybandaid.net'
|
||||
__version__ = '0.1.1'
|
||||
@ -1,97 +0,0 @@
|
||||
# coding=utf8
|
||||
"""Sopel Kick
|
||||
|
||||
Sopel Kick is an easy way to kick users from channels
|
||||
"""
|
||||
|
||||
# pylama:ignore=W0611
|
||||
|
||||
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
|
||||
import sopel.bot
|
||||
from sopel import tools, module
|
||||
from sopel.tools import Identifier
|
||||
from sopel.config.types import StaticSection, ValidatedAttribute
|
||||
|
||||
import sopel_modules.SpiceBot as SpiceBot
|
||||
|
||||
|
||||
import time
|
||||
from collections import abc
|
||||
import sys
|
||||
|
||||
|
||||
__author__ = 'Sam Zick'
|
||||
__email__ = 'sam@deathbybandaid.net'
|
||||
__version__ = '0.1.2'
|
||||
|
||||
|
||||
def configure(config):
|
||||
config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False)
|
||||
config.SpiceBot_Kick.configure_setting('kick', 'MAXTARG limit for KICK')
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
||||
# Inject KICK
|
||||
SpiceBot.logs.log('SpiceBot_Kick', "Implanting Kick function into bot")
|
||||
bot.kick = SopelKICK.kick
|
||||
sopel.bot.SopelWrapper.kick = SopelWrapperKICK.kick
|
||||
|
||||
# verify config settings for server
|
||||
SpiceBot.logs.log('SpiceBot_Kick', "Checking for config settings")
|
||||
bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False)
|
||||
SpiceBot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False)
|
||||
|
||||
|
||||
@module.event('005')
|
||||
@module.rule('.*')
|
||||
def parse_event_005(bot, trigger):
|
||||
if trigger.args[-1] != 'are supported by this server':
|
||||
return
|
||||
parameters = trigger.args[1:-1]
|
||||
for param in parameters:
|
||||
if '=' in param:
|
||||
if param.startswith("TARGMAX"):
|
||||
param = str(param).split('=')[1]
|
||||
settings = str(param).split(',')
|
||||
for setting in settings:
|
||||
settingname = str(setting).split(':')[0]
|
||||
if settingname.upper() in ['KICK']:
|
||||
try:
|
||||
value = str(setting).split(':')[1] or None
|
||||
except IndexError:
|
||||
value = None
|
||||
if value:
|
||||
bot.config.SpiceBot_Kick.kick = int(value)
|
||||
|
||||
|
||||
class SpiceBot_Kick(StaticSection):
|
||||
kick = ValidatedAttribute('kick', default=1)
|
||||
|
||||
|
||||
class SopelKICK:
|
||||
|
||||
def kick(self, nick, channel, text=None):
|
||||
"""Send an IRC KICK command.
|
||||
Within the context of a triggered callable, ``channel`` will default to the
|
||||
channel in which the call was triggered. If triggered from a private message,
|
||||
``channel`` is required (or the call to ``kick()`` will be ignored).
|
||||
The bot must be a channel operator in specified channel for this to work.
|
||||
.. versionadded:: 7.0
|
||||
"""
|
||||
self.write(['KICK', channel, nick], text)
|
||||
|
||||
|
||||
class SopelWrapperKICK(object):
|
||||
|
||||
def kick(self, nick, channel=None, message=None):
|
||||
if channel is None:
|
||||
if self._trigger.is_privmsg:
|
||||
raise RuntimeError('Error: KICK requires a channel.')
|
||||
else:
|
||||
channel = self._trigger.sender
|
||||
if nick is None:
|
||||
raise RuntimeError('Error: KICK requires a nick.')
|
||||
self._bot.kick(nick, channel, message)
|
||||
@ -1,8 +0,0 @@
|
||||
# coding=utf8
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
|
||||
from .Messaging import *
|
||||
|
||||
__author__ = 'Sam Zick'
|
||||
__email__ = 'sam@deathbybandaid.net'
|
||||
__version__ = '0.1.1'
|
||||
Loading…
Reference in New Issue
Block a user