コード例 #1
0
ファイル: gbot.py プロジェクト: PatrickKennedy/pygab
	def ev_msg(self, msg):
		user = utils.getjid(msg.from_user.getStripped())
		if user != utils.getjid(server.username):
			if self.hook(const.LOC_EV_MSG, msg):
				# TODO: Log all incoming to the console and
				# all outgoing to a file.
				logging.getLogger('pygab.chat').info('%s -> %s' % (
					utils.getnickname(msg.from_user), msg.text
				))
				return
			# self.log("<%s> %s" % (getnickname(user), msg))
			text = '<%s> %s' % (utils.getnickname(msg.from_user), msg.text)
			self.sendtoall(text, butnot=[unicode(user)])
コード例 #2
0
ファイル: gbot.py プロジェクト: PatrickKennedy/pygab
	def sendto(self, user, text):
		'''Send msg to user via self._send_msg'''
		logging.getLogger('pygab.chat').info('%s <- %s' % (utils.getnickname(user), text))
		message = self._build_msg(utils.getjid(user), text)
		if self.hook(const.LOC_SEND_MSG_PER_MSG, message):
			return

		self._send_msg(message)
コード例 #3
0
ファイル: plugin_info.py プロジェクト: PatrickKennedy/pygab
    def thread(self, user, args):
        statuses = {"admins": [], "online": [], "offline": [], "away": [], "idle": [], "busy": []}

        for sid in self.parent.getRoster():
            i = utils.getjid(sid)
            name = utils.getnickname(i)
            if name == iMan.config.server.username:
                continue

            if not utils.isonline(self.parent, sid):
                # statuses['offline'].append('(%s)' % name)
                continue

            jid_status = self.parent.getJidStatus(sid)

            for who, (status, display) in jid_status.iteritems():
                if "@" not in unicode(who):
                    continue
                if utils.isbanned(who):
                    name = "#%s" % name
                    continue

                if utils.isactive(self.parent, who):
                    if utils.isadmin(who):
                        name = "@%s" % name
                        # statuses['admins'].append(name)
                    elif utils.ismod(who):
                        name = "%" + "%s" % name
                        # statuses['admins'].append(name)
                    statuses["online"].append(name)
                    break

                    # Anyone not "available".
                elif utils.isaway(self.parent, who):
                    if status in [u"away", u"xa"]:
                        name = "-%s" % name
                        statuses["idle"].append(name)
                    elif status == u"dnd":
                        name = "!%s" % name
                        statuses["busy"].append(name)
                    break

                    # Setup the header with a header for total number of users.
        reply = "Users (%s):\n"
        total = 0
        for status, users in statuses.iteritems():
            if not users:
                continue
            reply += "%s (%s): %s\n" % (status, len(users), " ".join(users))
            total += len(users)

            # Tack on the total number of users.
        reply = reply % total

        self.parent.sendto(user, reply)
コード例 #4
0
ファイル: gbot.py プロジェクト: ggppjj/crunchybot
	def ev_msg(self, user, msg, raw_msg):
		user = utils.getjid(user.getStripped())
		# Is this a command?
		if msg[:1] in iMan.config.system.commandprefix:
			self.command(user, msg[1:])
		elif user != utils.getjid(server.username):
			if self.hook(const.LOC_EV_MSG, user, msg):
				# self.log("<%s> %s" % (getnickname(user), msg))
				self.sendtoall("<%s> %s" % (utils.getnickname(user), msg),
							   butnot=[unicode(user)]
				)