예제 #1
0
파일: userclass.py 프로젝트: SnoFox/pyfox
def sr_352( irc, client, target, params ):
# >> :dualcore.ext3.net 352 PyFox #foxtest ~SnoFox is.in-addr.arpa void.ext3.net SnoFox H*! :2 Fox of Sno
	chan = ircStrLower( irc, params[0] )
	ident = params[1]
	address = params[2]
	nick = params[4]
	prefix = params[5] # need to be cleaned
	gecos = ' '.join( params[7:] )

	realPrefix = ""
	for char in prefix:
		if char in irc.statusmodes:
			realPrefix += char
	# Now translate !@%+ to aohv
	prefix = ""
	for thisPrefix in realPrefix:
		prefix += irc.statusmodes[ thisPrefix ]

	user = None
	for thisUser in irc.userList:
		if ircStrCmp( irc, thisUser.getNick(), nick ):
			user = thisUser
			break
	if not user:
		user = User( irc, nick )
		user.setIdent( ident )
		user.setAddress( address )
		user.setGecos( gecos )

	user.addChan( chan, prefix )
예제 #2
0
파일: userclass.py 프로젝트: SnoFox/pyfox
def sr_nick( irc, client, newNick, null ):
	user = None
	for thisUser in irc.userList:
		if ircStrCmp( irc, thisUser.getNick(), client[0] ):
			user = thisUser
			break
	if user:
		user.changeNick( newNick.strip( ":" ) )
	else:
		print "Error: got nick change for %s -> %s, but we don't know them" % ( client[0], newNick )
예제 #3
0
파일: userclass.py 프로젝트: SnoFox/pyfox
def sr_quit( irc, client, reason, null ):
	user = None
	for thisUser in irc.userList:
		if ircStrCmp( irc, thisUser.getNick(), client[0] ):
			user = thisUser
			break
	if not user:
		print "Error: got a quit for user we don't know about: %s!%s@%s" % ( client[0], client[1], client[2] )
	else:
		irc.userList.remove( user )
예제 #4
0
파일: userclass.py 프로젝트: SnoFox/pyfox
def sr_join( irc, client, chan, null ):
	chan = chan.strip( ":" )

	if client[0] == irc.nick:
		irc.push( 'WHO %s' % chan )
	else:
		user = None
		for thisUser in irc.userList:
			if ircStrCmp( irc, thisUser.getNick(), client[0] ):
				user = thisUser
				break

		if not user:
			user = User( irc, client[0] )
			user.setIdent( client[1] )
			user.setAddress( client[2] )

		user.addChan( ircStrLower( irc, chan ) )
예제 #5
0
파일: userclass.py 프로젝트: SnoFox/pyfox
def sr_kick( irc, client, chan, params ):
	chan = ircStrLower( irc, chan.strip( ":" ) )
	victim = params[0]

	if victim == irc.nick: # I left the channel
		tempList = list( irc.userList )
		for user in tempList:
			if chan in user.getChans():
				user.delChan( chan )
				if len( user.getChans() ) == 0:
					irc.userList.remove( user )
	else:	
		user = None
		for thisUser in irc.userList:
			if ircStrCmp( irc, thisUser.getNick(), victim ):
				user = thisUser
				break
		if not user:
			print "Error: got a kick for user we don't know about: %s kicking %s in %s" % ( client[0], victim, chan)
		else:
			user.delChan( ircStrLower( irc, chan ) )
예제 #6
0
파일: userclass.py 프로젝트: SnoFox/pyfox
def sr_part( irc, client, chan, reason ):
	chan = chan.strip( ":" )
	if client[0] == irc.nick: # I left the channel
		tempList = list( irc.userList )
		for user in tempList:
			if chan in user.getChans():
				user.delChan( chan )
				if len( user.getChans() ) == 0:
					irc.userList.remove( user )
	else:
		user = None
		for thisUser in irc.userList:
			if ircStrCmp( irc, thisUser.getNick(), client[0] ):
				user = thisUser
				break
		if not user:
			print "Error: got a part for user we don't know about: %s!%s@%s on %s" % ( client[0], client[1], client[2], chan )
		else:
			user.delChan( ircStrLower( irc, chan ) )
			if len( user.getChans() ) == 0:
				irc.userList.remove( user )
예제 #7
0
파일: userclass.py 프로젝트: SnoFox/pyfox
def sr_mode(irc, client, target, params):
	# XXX: Icky, code duplication. Could add a prefix-change event to prevent this
	# Mode parser
	# Sends out mode events for other modules to use
	# - SnoFox

	if target[0] in irc.isupport['CHANTYPES']:
		chmode = True 
		target = ircStrLower( irc, target )
	else:
		chmode = False
	
	adding = True # true = adding a mode; false = removing
	paramNum = 1  # count of which param we're using 

	# XXX: This will crash the bot if the IRCd lied to us in the 005 version string
	# then later sends us a mode line that doesn't agree with our knowledge of modes
	# That ... Should probably be fixed.
	for char in params[0]:
		if char == '+':
			adding = True
		elif char == '-':
			adding = False
		else:
			param = None

			if chmode:
				if char in irc.listmodes or char in irc.typebmodes or (char in irc.typecmodes and adding):
					paramNum += 1
					continue

				if char in irc.typeemodes:
					# We only care about prefix modes here
					user = None
					for thisUser in irc.userList:
						if ircStrCmp( irc, thisUser.getNick(), params[ paramNum ] ):
							user = thisUser

					if user:
						if adding:
							prefixes = user.getPrefix( target )
							if not char in prefixes:
								prefixes += char
								user.setPrefix( target, prefixes )
						else:
							prefixes = user.getPrefix( target )
							newPrefixes = ""
							for thisPrefix in prefixes:
								if not thisPrefix == char:
									newPrefixes += char
							user.setPrefix( target, newPrefixes )

					else: 
						print "Error: nick %s in %s got a prefix, but I don't know who he is" % ( params[ paramNum ], target )

					paramNum += 1
					continue
				else:
					# flag type mode; we don't care here
					pass
			else:
				# Usermode get
				# not a f**k was given that mode
				pass