<commit_before># -*- coding: utf-8 -*-

import os
import datetime
import logging
import functools
import asyncio

import irc.bot
import irc.client
import irc.connection
import sqlalchemy
from sqlalchemy.dialects.postgresql import insert

from common import FRAMEWORK_ONLY
from common import game_data
from common import postgres
from common import slack
from common import state
from common import twitch
from common import utils
from common.config import config
from common.pubsub import PubSub

from lrrbot import asyncreactor
from lrrbot import cardviewer
from lrrbot import chatlog
from lrrbot import command_parser
from lrrbot import decorators
from lrrbot import desertbus_moderator_actions
from lrrbot import join_filter
from lrrbot import linkspam
from lrrbot import moderator_actions
from lrrbot import rpc
from lrrbot import spam
from lrrbot import storage
from lrrbot import stream_status
from lrrbot import systemd
from lrrbot import twitchcheer
from lrrbot import twitchfollows
from lrrbot import twitchsubs
from lrrbot import video_playback
from lrrbot import whisper

log = logging.getLogger('lrrbot')

SELF_METADATA = {'specialuser': {'mod', 'subscriber'}, 'usercolor': '#FF0000', 'emoteset': {317}}

class LRRBot(irc.bot.SingleServerIRCBot):
	game_override = state.Property("lrrbot.main.game_override")
	show_override = state.Property("lrrbot.main.show_override")
	access = state.Property("lrrbot.main.access", "all")
	show_id = state.Property("lrrbot.main.show_id")
	polls = state.Property("lrrbot.main.polls", [])
	cardview = state.Property("lrrbot.main.cardview", False)

	def __init__(self, loop):
		self.engine, self.metadata = postgres.get_engine_and_metadata()
		users = self.metadata.tables["users"]
		if config['password'] == "oauth":
			with self.engine.begin() as conn:
				row = conn.execute(sqlalchemy.select([users.c.twitch_oauth])
					.where(users.c.name == config['username'])).first()
				if row is not None:
					password, = row
				else:
					password = ""
				if password is None:
					password = ""
			password = "<PASSWORD>:" + password
		else:
			password = config['password']
		self.loop = loop
		server = irc.bot.ServerSpec(
			host=config['hostname'],
			port=config['port'],
			password=password,
		)
		if config['secure']:
			import ssl
			connect_factory = irc.connection.Factory(wrapper=ssl.wrap_socket)
		else:
			connect_factory = irc.connection.Factory()
		super(LRRBot, self).__init__(
			server_list=[server],
			realname=config['username'],
			nickname=config['username'],
			reconnection_interval=config['reconnecttime'],
			connect_factory=connect_factory,
		)

		# Send a keep-alive message every minute, to catch network dropouts
		# self.connection has a set_keepalive method, but it crashes
		# if it triggers while the connection is down, so do this instead
		self.reactor.scheduler.execute_every(config['keepalivetime'], self.do_keepalive)
		self.reactor.add_global_handler('pong', self.on_pong)
		self.missed_pings = 0

		self.reactor.add_global_handler('reconnect', self.disconnect)

		self.reactor.scheduler.execute_every(5, self.check_polls)

		self.service = systemd.Service(loop)
<commit_msg>Deprecated param removed in latest version of irc library<commit_after># -*- coding: utf-8 -*-

import os
import datetime
import logging
import functools
import asyncio

import irc.bot
import irc.client
import irc.connection
import sqlalchemy
from sqlalchemy.dialects.postgresql import insert

from common import FRAMEWORK_ONLY
from common import game_data
from common import postgres
from common import slack
from common import state
from common import twitch
from common import utils
from common.config import config
from common.pubsub import PubSub

from lrrbot import asyncreactor
from lrrbot import cardviewer
from lrrbot import chatlog
from lrrbot import command_parser
from lrrbot import decorators
from lrrbot import desertbus_moderator_actions
from lrrbot import join_filter
from lrrbot import linkspam
from lrrbot import moderator_actions
from lrrbot import rpc
from lrrbot import spam
from lrrbot import storage
from lrrbot import stream_status
from lrrbot import systemd
from lrrbot import twitchcheer
from lrrbot import twitchfollows
from lrrbot import twitchsubs
from lrrbot import video_playback
from lrrbot import whisper

log = logging.getLogger('lrrbot')

SELF_METADATA = {'specialuser': {'mod', 'subscriber'}, 'usercolor': '#FF0000', 'emoteset': {317}}

class LRRBot(irc.bot.SingleServerIRCBot):
	game_override = state.Property("lrrbot.main.game_override")
	show_override = state.Property("lrrbot.main.show_override")
	access = state.Property("lrrbot.main.access", "all")
	show_id = state.Property("lrrbot.main.show_id")
	polls = state.Property("lrrbot.main.polls", [])
	cardview = state.Property("lrrbot.main.cardview", False)

	def __init__(self, loop):
		self.engine, self.metadata = postgres.get_engine_and_metadata()
		users = self.metadata.tables["users"]
		if config['password'] == "oauth":
			with self.engine.begin() as conn:
				row = conn.execute(sqlalchemy.select([users.c.twitch_oauth])
					.where(users.c.name == config['username'])).first()
				if row is not None:
					password, = row
				else:
					password = ""
				if password is None:
					password = ""
			password = "<PASSWORD>:" + password
		else:
			password = config['password']
		self.loop = loop
		server = irc.bot.ServerSpec(
			host=config['hostname'],
			port=config['port'],
			password=password,
		)
		if config['secure']:
			import ssl
			connect_factory = irc.connection.Factory(wrapper=ssl.wrap_socket)
		else:
			connect_factory = irc.connection.Factory()
		super(LRRBot, self).__init__(
			server_list=[server],
			realname=config['username'],
			nickname=config['username'],
			recon=irc.bot.ExponentialBackoff(
				min_interval=config['reconnecttime'],
				max_interval=config['reconnecttime'],
			),
			connect_factory=connect_factory,
		)

		# Send a keep-alive message every minute, to catch network dropouts
		# self.connection has a set_keepalive method, but it crashes
		# if it triggers while the connection is down, so do this instead
		self.reactor.scheduler.execute_every(config['keepalivetime'], self.do_keepalive)
		self.reactor.add_global_handler('pong', self.on_pong)
		self.missed_pings = 0

		self.reactor.add_global_handler('reconnect', self.disconnect)

		self.reactor.scheduler.execute_every(5, self.check_polls)

		self.service = systemd.Service(loop)

{'fraction_non_alphanumeric': 0.09812140971898774, 'fraction_numerical': 0.0031051079024996117, 'mean_word_length': 5.1061611374407585, 'pattern_counts': {'":': 2, '<': 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': '5061453', 'n_tokens_mistral': 2228, 'n_tokens_neox': 2023, 'n_words': 544}