# Path: helpers/chatHelper.py
# def joinChannel(userID = 0, channel = "", token = None, toIRC = True, force=False):
# def partChannel(userID = 0, channel = "", token = None, toIRC = True, kick = False, force=False):
# def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
# def fixUsernameForBancho(username):
# def fixUsernameForIRC(username):
# def IRCConnect(username):
# def IRCDisconnect(username):
# def IRCJoinChannel(username, channel):
# def IRCPartChannel(username, channel):
# def IRCAway(username, message):
# 
# Path: objects/glob.py
# 		VERSION = f.read().strip()
# 	VERSION = "Unknown"
# DATADOG_PREFIX = "peppy"


import hashlib
import re
import select
import socket
import sys
import time
import traceback
import raven
from common.log import logUtils as log
from common.ripple import userUtils
from helpers import chatHelper as chat
from objects import glob


	def reply461(self, command):
		"""
		Add a 461 reply (not enough parameters) to client buffer

		:param command: name of the command that had not enough parameters
		:return:
		"""
		self.replyCode(403, "{} :Not enough parameters".format(command))


	def disconnect(self, quitmsg = "Client quit", callLogout = True):
		"""
		Disconnects this client from the IRC server

		:param quitmsg: IRC quit message. Default: 'Client quit'
		:param callLogout: if True, call logoutEvent on bancho
		:return:
		"""
		# Send error to client and close socket
		self.message("ERROR :{}".format(quitmsg))
		self.socket.close()
		log.info("[IRC] Disconnected connection from {}:{} ({})".format(self.ip, self.port, quitmsg))

		# Remove socket from server
		self.server.removeClient(self, quitmsg)

		# Bancho logout
		if callLogout and self.banchoUsername != "":

# Path: helpers/chatHelper.py
# def joinChannel(userID = 0, channel = "", token = None, toIRC = True, force=False):
# def partChannel(userID = 0, channel = "", token = None, toIRC = True, kick = False, force=False):
# def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
# def fixUsernameForBancho(username):
# def fixUsernameForIRC(username):
# def IRCConnect(username):
# def IRCDisconnect(username):
# def IRCJoinChannel(username, channel):
# def IRCPartChannel(username, channel):
# def IRCAway(username, message):
# 
# Path: objects/glob.py
# 		VERSION = f.read().strip()
# 	VERSION = "Unknown"
# DATADOG_PREFIX = "peppy"


# Path: irc/ircserver.py
import hashlib
import re
import select
import socket
import sys
import time
import traceback
import raven
from common.log import logUtils as log
from common.ripple import userUtils
from helpers import chatHelper as chat
from objects import glob



	def reply461(self, command):
		"""
		Add a 461 reply (not enough parameters) to client buffer

		:param command: name of the command that had not enough parameters
		:return:
		"""
		self.replyCode(403, "{} :Not enough parameters".format(command))


	def disconnect(self, quitmsg = "Client quit", callLogout = True):
		"""
		Disconnects this client from the IRC server

		:param quitmsg: IRC quit message. Default: 'Client quit'
		:param callLogout: if True, call logoutEvent on bancho
		:return:
		"""
		# Send error to client and close socket
		self.message("ERROR :{}".format(quitmsg))
		self.socket.close()
		log.info("[IRC] Disconnected connection from {}:{} ({})".format(self.ip, self.port, quitmsg))

		# Remove socket from server
		self.server.removeClient(self, quitmsg)

		# Bancho logout
		if callLogout and self.banchoUsername != "":

			chat.IRCDisconnect(self.IRCUsername)