<commit_before>###
# Copyright (c) 2015, PrgmrBill
# Based on work by Copyright (c) 2010, melodeath
# All rights reserved.
#
#
###

import supybot.utils as utils
from supybot.commands import *
import supybot.plugins as plugins
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
import supybot.ircmsgs as ircmsgs
import requests
import json
import supybot.schedule as schedule

try:
	from supybot.i18n import PluginInternationalization
	_ = PluginInternationalization('SpiffyRadio')
except ImportError:
	# Placeholder that allows to run the plugin on a bot
	# without the i18n module
	_ = lambda x: x

class SpiffyRadio(callbacks.Plugin):
	"""Radio information for Icecast 2 streams"""
	threaded = True
	auto_announce_interval = None
	last_track = None
	track_has_changed = False

	def __init__(self, irc):
		self.__parent = super(SpiffyRadio, self)
		self.__parent.__init__(irc)
		self.irc = irc

		if self.registryValue("autoAnnounceNewTracks"):
			try:
				schedule.removeEvent("SpiffyRadioAutoAnnounce")
			except:
				pass

			self.set_auto_announce_interval()

	def set_auto_announce_interval(self):
		interval = self.registryValue("pollingIntervalInSeconds")

		if not self.auto_announce_interval:
			self.auto_announce_interval = schedule.addPeriodicEvent(self.announce_to_channels, 
																	interval,
																	"SpiffyRadioAutoAnnounce")

	def announce_to_channels(self):
		channels = list(self.registryValue("autoAnnounceChannels"))

		try:<commit_msg>SpiffyRadio: remove announcement interval on unload<commit_after>###
# Copyright (c) 2015, PrgmrBill
# Based on work by Copyright (c) 2010, melodeath
# All rights reserved.
#
#
###

import supybot.utils as utils
from supybot.commands import *
import supybot.plugins as plugins
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
import supybot.ircmsgs as ircmsgs
import requests
import json
import supybot.schedule as schedule

try:
	from supybot.i18n import PluginInternationalization
	_ = PluginInternationalization('SpiffyRadio')
except ImportError:
	# Placeholder that allows to run the plugin on a bot
	# without the i18n module
	_ = lambda x: x

class SpiffyRadio(callbacks.Plugin):
	"""Radio information for Icecast 2 streams"""
	threaded = True
	auto_announce_interval = None
	last_track = None
	track_has_changed = False

	def __init__(self, irc):
		self.__parent = super(SpiffyRadio, self)
		self.__parent.__init__(irc)
		self.irc = irc

		if self.registryValue("autoAnnounceNewTracks"):
			self.set_auto_announce_interval()

	def set_auto_announce_interval(self):
		interval = self.registryValue("pollingIntervalInSeconds")

		self.remove_announce_interval()

		if not self.auto_announce_interval:
			self.auto_announce_interval = schedule.addPeriodicEvent(self.announce_to_channels, 
																	interval,
																	"SpiffyRadioAutoAnnounce")

	def remove_announce_interval(self):
		try:
			schedule.removeEvent("SpiffyRadioAutoAnnounce")
			self.auto_announce_interval = None
		except:
			pass

	def doUnload(self):
		self.log.info("SpiffyRadio: unloading!")

		self.remove_announce_interval()

	def announce_to_channels(self):
		channels = list(self.registryValue("autoAnnounceChannels"))

		try:
{'fraction_non_alphanumeric': 0.08045622688039457, 'fraction_numerical': 0.008014796547472256, 'mean_word_length': 4.921532846715328, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7018506', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1022, 'n_words': 254}