<commit_before>#! /usr/bin/env python
#
# IRC2LCD
# <NAME>
#
"""IRC bot to display mentions on an LCD through a Parallax Propeller.

Usage: IRCbot2LCD.py <server[:port]> <channel> <nicknameToMonitor> <COMport> <optional bot nickname>

"""
#
# Modified from:
# Example program using irc.bot.
# <NAME> <<EMAIL>>
#

import irc.bot
import irc.strings
from irc.client import ip_numstr_to_quad, ip_quad_to_numstr
import re
import serial
import time


class IRC2LCDbot(irc.bot.SingleServerIRCBot):
	def __init__(self, channel, nickname, server, port=6667):
		irc.bot.SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname)
		self.channel = channel

	def on_nicknameinuse(self, c, e):
		c.nick(BotNick)

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

	def on_pubmsg(self, c, e):
		pubmsgTemp = e.arguments[0]	# e.arguments[0] is the public message we are processing, loaded into "pubmsgTemp"
		pattern = re.compile(r'(.*{0}\s.*|.*{1}:.*)'.format(MonitorNick,MonitorNick))	# Compile Regular Expression to check if the public message has our MonitorNick in it
		result = re.search(pattern, pubmsgTemp)	# Execute Regular Expression
		if result:	# Check to see if we matched our MonitorNick in the public message
			try:	# Handle error when result has 'None' in it
				print result.group(1)	# Print matched message to the console
				MatchedMessage = str(result.group(1))	# Load matched message into "MatchedMessage" variable. Enclosing it in "str()" is to return a nice printable string.
				ser.write("\r\t" + MatchedMessage)	# Write "MatchedMessage" to LCD through Parallax Propeller over Serial connection. "\r\t" is command for Propeller to Clear LCD.
			except:	# Needed to complete 'try:' statement
				pass	# Do nothing and move on

def main():
	import sys
	if len(sys.argv) < 5:
		print("Usage: IRCbot2LCD.py <server[:port]> <channel> <nicknameToMonitor> <COMport> <optional bot nickname>")
		sys.exit(1)
<commit_msg>Fixed so that we don't accidentally monitor our Bot<commit_after>#! /usr/bin/env python
#
# IRC2LCD
# <NAME>
#
"""IRC bot to display mentions on an LCD through a Parallax Propeller.

Usage: IRCbot2LCD.py <server[:port]> <channel> <nicknameToMonitor> <COMport> <optional bot nickname>

"""
#
# Modified from:
# Example program using irc.bot.
# <NAME> <<EMAIL>>
#

import irc.bot
import irc.strings
from irc.client import ip_numstr_to_quad, ip_quad_to_numstr
import re
import serial
import time


class IRC2LCDbot(irc.bot.SingleServerIRCBot):
	def __init__(self, channel, nickname, server, port=6667):
		irc.bot.SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname)
		self.channel = channel

	def on_nicknameinuse(self, c, e):
		c.nick(BotNick)

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

	def on_pubmsg(self, c, e):
		pubmsgTemp = e.arguments[0]	# e.arguments[0] is the public message we are processing, loaded into "pubmsgTemp"
		pattern = re.compile(r'(.*{0}([|_][a-z0-9]+)?(\s|$).*|.*{1}([|_][a-z0-9]+)?:.*)'.format(MonitorNick,MonitorNick))	# Compile Regular Expression to check if the public message has our MonitorNick in it
		result = re.search(pattern, pubmsgTemp)	# Execute Regular Expression
		if result:	# Check to see if we matched our MonitorNick in the public message
			try:	# Handle error when result has 'None' in it
				print result.group(1)	# Print matched message to the console
				MatchedMessage = str(result.group(1))	# Load matched message into "MatchedMessage" variable. Enclosing it in "str()" is to return a nice printable string.
				ser.write("\r\t" + MatchedMessage)	# Write "MatchedMessage" to LCD through Parallax Propeller over Serial connection. "\r\t" is command for Propeller to Clear LCD.
			except:	# Needed to complete 'try:' statement
				pass	# Do nothing and move on

def main():
	import sys
	if len(sys.argv) < 5:
		print("Usage: IRCbot2LCD.py <server[:port]> <channel> <nicknameToMonitor> <COMport> <optional bot nickname>")
		sys.exit(1)

{'fraction_non_alphanumeric': 0.1218955904713634, 'fraction_numerical': 0.00912316269640142, 'mean_word_length': 4.712011577424023, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 31, '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': '6048606', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1306, 'n_words': 432}