示例#1
0
def cmd_quit(currentServer, currentChannel, args):
	"""
		Quit the given server with an optional reason.
		If no server is given, the current server is quit.

		Usage: /quit <server> [<reason>]
			   /quit [<reason>]
	"""
	if args:
		# /quit <server> [<reason>]
		if gui.tabs.search_tab(args[0]):
			reason = " ".join(args[1:])
			if not reason:
				reason = config.get("chatting", "quit_message", "")
			sushi.quit(args[0], reason)
		else:
			# /quit [<reason>]
			if not currentServer:
				return gui.mgmt.myPrint("Could not determine server.")
			reason = " ".join(args)
			if not reason:
				reason = config.get("chatting", "quit_message", "")
			sushi.quit(currentServer.name, reason)
	else:
		# /quit
		if not currentServer:
			return gui.mgmt.myPrint("Could not determine server.")
		sushi.quit(currentServer.name,
			config.get("chatting", "quit_message", ""))
示例#2
0
def cmd_part(currentServer, currentChannel, args):
	"""
		Part the given channel with an optional reason.
		If no channel is given, the current channel is parted.

		Usage: /part <channel> [<reason>]
			   /part [<reason>]
	"""
	if args and currentServer:
		# /part <channel> [<reason>]
		if gui.tabs.search_tab(currentServer.name, args[0]):
			reason = " ".join(args[1:])
			if not reason:
				reason = config.get("chatting", "part_message", "")
			sushi.part(currentServer.name, args[0], reason)
		else:
			# /part [<reason>]
			if not currentChannel:
				return gui.mgmt.myPrint("Could not determine channel.")
			reason = " ".join(args)
			if not reason:
				reason = config.get("chatting", "part_message", "")
			sushi.part(currentServer.name, currentChannel.name, reason)
	else:
		# /part
		if not currentChannel:
			return gui.mgmt.myPrint("Could not determine channel.")
		sushi.part(currentServer.name, currentChannel.name, config.get("chatting", "part_message", ""))
示例#3
0
	def get_config(self, name, default = None):

		section = "plugin_%s" % (self._plugin_name)

		return config.get(section, name, default)
示例#4
0
	def request(server,channel):
		""" print the name listing in the queried tab (if it's active)
			or in the current tab
		"""
		def names_cb(time, server, channel, nicks, prefixes):

			self = names_cb

			def print_message(message):
				if self.tab.is_active():
					# print in the channel we query
					self.tab.write(time, message, "action")
				elif self.tab.is_server():
					self.tab.current_write(time, message, "action")
				else:
					# print in the current channel
					self.tab.server.current_write(time, message, "action")

			if self.first:
				print_message(_("• Begin of names"))
				self.first = False

			if not nicks: # eol
				signals.disconnect_signal("names", self)
				print_message(_("• End of names"))

			else:
				max_nicklen = max([len(n)+len(p)
					for (p,n) in self.tab.nickList.get_nicks_mode()])

				message = ""
				for i in xrange(len(nicks)):
					nick_color = color.get_nick_color(nicks[i])

					c_start = "<font foreground='%s'>" % (nick_color)
					c_end = "</font>"

					tmp = "[{prefix}{cstart}{nick}{cend}]".format(
						prefix=prefixes[i],
						nick=nicks[i],
						cstart=c_start,
						cend=c_end)

					overhead = len(tmp) - len(nicks[i]) - len(prefixes[i])

					message += "{0:{align}<{fill}}".format(tmp,
									align=" ", fill=max_nicklen + overhead)

					if (i+1) % self.max_col == 0:
						print_message(message)
						message = ""
					else:
						message += " "

				print_message(message)


		names_cb.first = True
		names_cb.max_col = int(config.get("tekka","names_columns"))
		s,c = gui.tabs.search_tabs(server, channel)
		names_cb.tab = c or s

		signals.connect_signal("names", names_cb)
		sushi.names(server, channel)