예제 #1
0
def getResp(cur_item, user_name=None, user_id=None, msg_local_id=None, is_mod=False, is_owner=False, websocket=None):

	goodbye = False

	config = _updateConfig()

	# ----------------------------------------------------------
	# Commands
	# ----------------------------------------------------------
	cmd = cur_item[1:].split()

	if len(cmd) < 1:
		return None, False	# It's a single "!" character, so return None (not a command)

	if cmd[0][0:5] == "blame":	# Blame a user
		response = responses.blame(user_name, cur_item, is_mod, is_owner)

	elif cmd[0] == "commands":		# Get list of commands
		response = responses.cmdList(user_name, cur_item, is_mod, is_owner)

	elif cmd[0] == "hey":				# Say hey
		response = responses.hey(user_name, is_mod, is_owner)

	elif cmd[0] == "ping":				# Ping Pong Command
		response = responses.ping(user_name, is_mod, is_owner)

	elif (cmd[0] == config["currency_name"] or
		cmd[0] == config["currency_cmd"] or
	 	cmd[0] == "currency"):			# Get user balance
		currency_ret, user = responses.dimes(user_name, cur_item, is_mod, is_owner)

		if currency_ret != False or currency_ret != None:
			response = "@" + user + " has " + currency_ret + " " + config['currency_name'] + "!"
		else:
			response = "@" + user + " has no " + config['currency_name'] + "! :o"

	elif cmd[0] == "give":	# Give dimes to a user
		response = responses.give(user_name, cur_item, is_mod, is_owner)

	elif cmd[0] == "ban":	# Ban a user from chatting
		response, banUser = responses.ban(user_name, cur_item, is_mod, is_owner)
		if banUser != "":
			bannedUsers.append(banUser)

		print ("bannedUsers",bannedUsers)

		pickle.dump(bannedUsers, open('data/bannedUsers{}.p'.format(config['CHANNEL']), "wb"))

	elif cmd[0] == "unban":	# Unban a user
		response, uBanUser = responses.unban(user_name, cur_item, is_mod, is_owner)
		if uBanUser != "":
			bannedUsers.remove(uBanUser)

		print ("bannedUsers",bannedUsers)

		pickle.dump(bannedUsers, open('data/bannedUsers{}.p'.format(config['CHANNEL']), "wb"))

	elif cmd[0] == "quote":	# Get random quote from DB
		response = responses.quote(user_name, cur_item, is_mod, is_owner)

	elif cmd[0] == "tackle":# Tackle a user!
		response = responses.tackle(user_name, cur_item, is_mod, is_owner)

	elif cmd[0] == "slap":	# Slap someone
		response = responses.slap(user_name, is_mod, is_owner)

	elif cmd[0] == "set":	# Bot configuration - Uses cmd instead of cur_item
		response = responses.set(user_name, user_id, cmd, is_mod, is_owner)

	elif cmd[0] == "schedule":	# Run commands at set intervals
		response = responses.schedule(user_name, cmd, is_mod, is_owner, websocket)

	elif cmd[0] == "store":		# List the items for sale
		response = responses.store(user_name, cmd, is_mod, is_owner)

	elif cmd[0] == "buy":		# Buy something from store using currency
		response = responses.store_buy(user_name, cmd, is_mod, is_owner)

	elif cmd[0] == "uptime":# Bot uptime
		response = responses.uptime(user_name, initTime, is_mod, is_owner)

	elif cmd[0] == "hug":	# Give hugs!
		response = responses.hug(user_name, cur_item, is_mod, is_owner)

	elif cmd[0] == "raid":	# Go raid peoples
		response = responses.raid(user_name, cur_item, is_mod, is_owner)

	elif cmd[0] == "raided":	# You done got raided son!
		response = responses.raided(user_name, cur_item, is_mod, is_owner)

	elif cmd[0] == "twitch":	# Go raid peoples on Twitch.tv!
		response = responses.twitch(user_name, cur_item, is_mod, is_owner)

	elif cmd[0] == "whoami":	# Who am I? I'M A GOAT. DUH.
		response = responses.whoami(user_name, is_mod, is_owner)

	elif cmd[0] == "command":	# Add command for any users
		if len(cmd) <= 2:	# It's not long enough to have a response
			return usage.prepCmd(user_name, "command", is_mod, is_owner), False

		if cmd[1] == "add":
			response = responses.command(user_name, cur_item, is_mod, is_owner)
		elif cmd[1] == "remove":
			response = responses.commandRM(user_name, cur_item, is_mod, is_owner)
		elif cmd[1] == "update":
			response = responses.editCommand(user_name, cur_item, is_mod, is_owner, is_mod_only=False)
		else:					# Not add or remove, return usage
			response = usage.prepCmd(user_name, "command", is_mod, is_owner)

	elif cmd[0] == "command+":	# Add mod-only command
		if len(cmd) <= 2:	# It's not long enough to have a response
			return usage.prepCmd(user_name, "command", is_mod, is_owner), False

		if cmd[1] == "add":
			response = responses.commandMod(user_name, cur_item, is_mod, is_owner)
		elif cmd[1] == "remove":
			response = responses.commandRM(user_name, cur_item, is_mod, is_owner)
		elif cmd[1] == "update":
			response = responses.editCommand(user_name, cur_item, is_mod, is_owner, is_mod_only=True)
		else:					# Not add or remove, return usage
			response = usage.prepCmd(user_name, "command+", is_mod, is_owner)

	elif cmd[0] == "goodbye":	# Turn off the bot correctly
		return control.goodbye(user_name, is_owner, msg_local_id)

	else:					# Unknown or custom command
		response = responses.custom(user_name, cur_item, is_mod, is_owner)

	print ('command:\t',cmd,'\n',
		'response:\t',response,'\n')	# Console logging

	return response, False 		# Return the response to calling statement
예제 #2
0
def getResp(curItem, userName=None, msgLocalID=None):

	# ----------------------------------------------------------
	# Commands
	# ----------------------------------------------------------
	cmd = curItem[1:].split()

	if cmd[0] == "hey":				# Say hey
		response = responses.hey(userName)

	elif cmd[0] == "ping":				# Ping Pong Command
		response = responses.ping(userName)

	elif cmd[0] == "dimes" or cmd[0] == "currency":			# Get user balance
		response = responses.dimes(userName, curItem)

	elif cmd[0] == "give":	# Give dimes to a user
		response = responses.give(userName, curItem)

	elif cmd[0] == "ban":	# Ban a user from chatting
		response, banUser = responses.ban(userName, curItem)
		bannedUsers.append(banUser)

		pickle.dump(bannedUsers, open('data/bannedUsers.p', "wb"))

	elif cmd[0] == "unban":	# Unban a user
		response, uBanUser = responses.unban(userName, curItem)
		bannedUsers.remove(uBanUser)

		pickle.dump(bannedUsers, open('data/bannedUsers.p', "wb"))

	elif cmd[0] == "quote": # Get random quote from DB
		response = responses.quote(userName, curItem)

	elif cmd[0] == "tackle":# Tackle a user!
		response = responses.tackle(userName, curItem)

	elif cmd[0] == "slap":	# Slap someone
		response = responses.slap(userName)

	elif cmd[0] == "uptime":# Bot uptime
		response = responses.uptime(userName, initTime)

	elif cmd[0] == "hug":	# Give hugs!
		response = responses.hug(userName, curItem)

	elif cmd[0] == "raid":	# Go raid peoples
		response = responses.raid(userName, curItem)

	elif cmd[0] == "raided":	# You done got raided son!
		response = responses.raided(userName, curItem)

	elif cmd[0] == "twitch":	# Go raid peoples on Twitch.tv!
		response = responses.twitch(userName, curItem)

	elif cmd[0] == "whoami":	# Who am I? I'M A GOAT. DUH.
		response = responses.whoami(userName)

	elif cmd[0] == "command":	# Add command for any users
		response = responses.command(userName, curItem)

	elif cmd[0] == "command+":	# Add mod-only command
		response = responses.commandMod(userName, curItem)

	elif cmd[0] == "command-":	# Remove a command
		response = responses.commandRM(userName, curItem)

	elif cmd[0] == "whitelist":	# Whitelist a user
		if len(cmd) >= 3:	# True means it has something like `add` or `remove`
			if cmd[1] == 'add':
				response = responses.whitelist(userName, curItem)
			elif cmd[1] == 'remove':
				response = responses.whitelistRM(userName, curItem)
			else: 	# Not add or remove
				response = None
		else:		# Just get the whitelist
			response = responses.whitelistLS(userName, curItem)

	elif cmd[0] == "goodbye":	# Turn off the bot correctly
		if is_owner or userName == 'ParadigmShift3d':
			packet = {
				"type":"method",
				"method":"msg",
				"arguments":['See you later my dear sir, wot wot!'],
				"id":msgLocalID
			}

			return packet, True	# Return the Goodbye message packet &
		else:		# Don't want anyone but owner killing the bot
			return None, False
	else:					# Unknown or custom command
		response = responses.custom(userName, curItem)

	print ('command:\t',cmd,'\n',
		'response:\t',response,'\n')	# Console logging

	return response, False 		# Return the response to calling statement