<commit_before>#! /usr/bin/python
import config
from irc.bot import SingleServerIRCBot

class MonsoonBot(SingleServerIRCBot):

	def __init__(self):
		super(MonsoonBot, self).__init__([(config.server, config.port)], config.nickname, config.nickname, 2)

	def is_authorized(self, sender):
		return config.channel in self.channels and self.channels[config.channel].is_oper(sender)

	def on_nicknameinuse(self, c, e):
		c.nick(c.get_nickname() + '_')

	def on_welcome(self, c, e):
		c.join(config.channel)

	def on_pubmsg(self, c, e):
		sender = e.source.nick
		message = e.arguments[0]
		print '<%s> %s' % (sender, message)

	def on_privmsg(self, c, e):
		sender = e.source.nick
		message = e.arguments[0]

		if self.is_authorized(sender):
			self.process_command(sender, message)

	def on_privnotice(self, c, e):
		sender = e.source.nick
		message = e.arguments[0]

		if self.is_authorized(sender):
			self.process_command(sender, message)

	def process_command(self, sender, message):
		print '*%s* %s' % (sender, message)
		
		if message == 'close':
			self.ircobj.disconnect_all()
			import sys; sys.exit()

if __name__ == '__main__':

	# Set loose decoding constraint
	from irc.client import ServerConnection
	ServerConnection.buffer_class.errors = 'replace'

	bot = MonsoonBot()
	bot.start()<commit_msg>Remove notice events, adding ability to halt process<commit_after>#! /usr/bin/python
import config
from irc.bot import SingleServerIRCBot

class MonsoonBot(SingleServerIRCBot):

	def __init__(self):
		super(MonsoonBot, self).__init__([(config.server, config.port)], config.nickname, config.nickname, 2)

	def is_authorized(self, sender):
		return config.channel in self.channels and self.channels[config.channel].is_oper(sender)

	def on_nicknameinuse(self, c, e):
		c.nick(c.get_nickname() + '_')

	def on_welcome(self, c, e):
		c.join(config.channel)

	def on_pubmsg(self, c, e):
		sender = e.source.nick
		message = e.arguments[0]
		print '<%s> %s' % (sender, message)

	def on_privmsg(self, c, e):
		sender = e.source.nick
		message = e.arguments[0]
		print '*%s* %s' % (sender, message)

		if self.is_authorized(sender):
			self.process_command(message)
		else:
			c.notice(sender, "Hi, this is Monsoon.")

	def process_command(self, message):
		if message == 'halt':
			# Shuts the connection and keep idle
			self.ircobj.disconnect_all()

		elif message == 'close':
			# Tore down the whole process
			self.ircobj.disconnect_all()
			import sys; sys.exit()


if __name__ == '__main__':

	# Set loose decoding constraint
	from irc.client import ServerConnection
	ServerConnection.buffer_class.errors = 'replace'

	bot = MonsoonBot()
	bot.start()
{'fraction_non_alphanumeric': 0.13285660519382764, 'fraction_numerical': 0.0026345502446368085, 'mean_word_length': 4.560669456066946, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1926538', 'n_tokens_mistral': 1014, 'n_tokens_neox': 917, 'n_words': 225}