collapsing all of dr_botzo one directory

This commit is contained in:
2017-02-04 11:48:55 -06:00
parent 38d14bb0d2
commit cd23f062a9
194 changed files with 0 additions and 0 deletions

View File

34
ircbot/ircplugins/echo.py Normal file
View File

@@ -0,0 +1,34 @@
import logging
from ircbot.lib import Plugin, reply_destination_for_event
log = logging.getLogger('ircbot.lib')
class Echo(Plugin):
"""Have IRC commands to do IRC things (join channels, quit, etc.)."""
def start(self):
"""Set up the handlers."""
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!echo\s+(.*)$',
self.handle_echo, -20)
super(Echo, self).start()
def stop(self):
"""Tear down handlers."""
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_echo)
super(Echo, self).stop()
def handle_echo(self, connection, event, match):
"""Handle the echo command... by echoing."""
return self.bot.reply(event, match.group(1))
plugin = Echo

View File

@@ -0,0 +1,66 @@
import logging
from ircbot.lib import Plugin, has_permission
from ircbot.models import IrcChannel
log = logging.getLogger('ircbot.ircplugins.ircmgmt')
class ChannelManagement(Plugin):
"""Have IRC commands to do IRC things (join channels, quit, etc.)."""
def start(self):
"""Set up the handlers."""
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!join\s+([\S]+)',
self.handle_join, -20)
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!part\s+([\S]+)',
self.handle_part, -20)
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!quit\s*(.*)',
self.handle_quit, -20)
super(ChannelManagement, self).start()
def stop(self):
"""Tear down handlers."""
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_join)
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_part)
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_quit)
super(ChannelManagement, self).stop()
def handle_join(self, connection, event, match):
"""Handle the join command."""
if has_permission(event.source, 'ircbot.manage_current_channels'):
channel = match.group(1)
# put it in the database if it isn't already
chan_mod, c = IrcChannel.objects.get_or_create(name=channel)
log.debug("joining channel %s", channel)
self.connection.join(channel)
return self.bot.reply(event, "Joined channel {0:s}.".format(channel))
def handle_part(self, connection, event, match):
"""Handle the join command."""
if has_permission(event.source, 'ircbot.manage_current_channels'):
channel = match.group(1)
# put it in the database if it isn't already
chan_mod, c = IrcChannel.objects.get_or_create(name=channel)
log.debug("parting channel %s", channel)
self.connection.part(channel)
return self.bot.reply(event, "Parted channel {0:s}.".format(channel))
def handle_quit(self, connection, event, match):
"""Handle the join command."""
if has_permission(event.source, 'ircbot.quit_bot'):
self.bot.die(msg=match.group(1))
plugin = ChannelManagement

View File

@@ -0,0 +1,48 @@
"""Watch channel topics for changes and note them."""
import logging
from django.utils import timezone
from ircbot.lib import Plugin
from ircbot.models import IrcChannel
log = logging.getLogger('ircbot.ircplugins.topicmonitor')
class TopicMonitor(Plugin):
"""Have IRC commands to do IRC things (join channels, quit, etc.)."""
def start(self):
"""Set up the handlers."""
self.connection.reactor.add_global_handler('topic', handle_topic, -20)
super(TopicMonitor, self).start()
def stop(self):
"""Tear down handlers."""
self.connection.reactor.remove_global_handler('topic', handle_topic)
super(TopicMonitor, self).stop()
def handle_topic(connection, event):
"""Store topic changes in the channel model."""
channel = event.target
topic = event.arguments[0]
setter = event.source
log.debug("topic change '%s' by %s in %s", topic, setter, channel)
channel, c = IrcChannel.objects.get_or_create(name=channel)
channel.topic_msg = topic
channel.topic_time = timezone.now()
channel.topic_by = setter
channel.save()
plugin = TopicMonitor