Ejemplo n.º 1
0
 def updateNicklist(self, user, remove = False) :
     group = weechat.nicklist_search_group(self.buffer, '', user.login)
     if group is not None and user.login in self.contacts :
         if user.fd in self.contacts[user.login] :
             weechat.nicklist_remove_nick(self.buffer, self.contacts[user.login][user.fd].nick)
             del self.contacts[user.login][user.fd]
         if remove is False :
             user.nick = weechat.nicklist_add_nick(self.buffer, group, ' :%s%s@%s%s' % (user.fd, weechat.color('separator'), weechat.color('default'), user.location), '', '', '', 1)
             self.contacts[user.login][user.fd] = user
Ejemplo n.º 2
0
def check_message(data, signal, signal_data):
    dict = weechat.info_get_hashtable("irc_message_parse",
                                      {"message": signal_data})
    nick = dict["nick"]
    channel = dict["channel"]
    if nick == "triggerbot":
        try:
            if channel.split("_")[1]:
                triggersafechannel = True
        except IndexError:
            triggersafechannel = False
        if triggersafechannel:
            buffer = weechat.info_get(
                "irc_buffer", "%s,%s" % (signal.split(",")[0], channel))
            group = weechat.nicklist_search_group(buffer, "", "triggerbot")
            if not group:
                group = weechat.nicklist_add_group(
                    buffer, "", "triggerbot", "weechat.color.nicklist_group",
                    1)
                triggerbotbuffers[buffer] = group
            # Is this a list of nicks?
            if dict["arguments"].find("Nicks %s: [" % channel) != -1:
                names = dict["arguments"].split(
                    "Nicks %s: [" % channel)[1].split("]")[0].split(" ")
                set_nicklist(names, buffer, group)
            # Is this a join message?
            elif dict["arguments"].split(":")[1].startswith(
                    "[INFO] ") and dict["arguments"].find(" has joined") != -1:
                name = dict["arguments"].split("[INFO] ")[1].split(
                    " has joined")[0]
                add_nick(name, buffer, group)
            # A leave message?
            elif dict["arguments"].split(":")[1].startswith(
                    "[INFO] ") and dict["arguments"].find(" has left") != -1:
                name = dict["arguments"].split("[INFO] ")[1].split(
                    " has left")[0]
                remove_nick(name, buffer, group)
            # A quit message? (Don't search for the dot here because a reason may be displayed)
            elif dict["arguments"].split(":")[1].startswith(
                    "[INFO] ") and dict["arguments"].find(" has quit") != -1:
                name = dict["arguments"].split("[INFO] ")[1].split(
                    " has quit")[0]
                remove_nick(name, buffer, group)
            elif dict["arguments"].split(":")[1].startswith(
                    "[INFO] "
            ) and dict["arguments"].find(" is now known as ") != -1:
                oldname = dict["arguments"].split("[INFO] ")[1].split(
                    " is now known as ")[0]
                newname = dict["arguments"].split("[INFO] ")[1].split(
                    " is now known as ")[1].split(".")[0]
                remove_nick(oldname, buffer, group)
                add_nick(newname, buffer, group)
    return weechat.WEECHAT_RC_OK
Ejemplo n.º 3
0
def check_message(data, signal, signal_data):
    dict = weechat.info_get_hashtable("irc_message_parse",
                                      {"message": signal_data})
    nick = dict["nick"]
    channel = dict["channel"]
    if nick == "triggerbot":
        try:
            if channel.split("_")[1]:
                triggersafechannel = True
        except IndexError:
            triggersafechannel = False
        if triggersafechannel:
            buffer = weechat.info_get("irc_buffer", "%s,%s" % (signal.split(",")[0], channel))
            group = weechat.nicklist_search_group(buffer, "", "triggerbot")
            if not group:
                group = weechat.nicklist_add_group(buffer, "", "triggerbot", "weechat.color.nicklist_group", 1)
                triggerbotbuffers[buffer] = group
            # Is this a list of nicks?
            if dict["arguments"].find("Nicks %s: [" % channel) != -1:
                names = dict["arguments"].split("Nicks %s: [" % channel)[1].split("]")[0].split(" ")
                set_nicklist(names, buffer, group)
            # Is this a join message?
            elif dict["arguments"].split(":")[1].startswith("[INFO] ") and dict["arguments"].find(" has joined") != -1:
                name = dict["arguments"].split("[INFO] ")[1].split(" has joined")[0]
                add_nick(name, buffer, group)
            # A leave message?
            elif dict["arguments"].split(":")[1].startswith("[INFO] ") and dict["arguments"].find(" has left") != -1:
                name = dict["arguments"].split("[INFO] ")[1].split(" has left")[0]
                remove_nick(name, buffer, group)
            # A quit message? (Don't search for the dot here because a reason may be displayed)
            elif dict["arguments"].split(":")[1].startswith("[INFO] ") and dict["arguments"].find(" has quit") != -1:
                name = dict["arguments"].split("[INFO] ")[1].split(" has quit")[0]
                remove_nick(name, buffer, group)
            elif dict["arguments"].split(":")[1].startswith("[INFO] ") and dict["arguments"].find(" is now known as ") != -1:
                oldname = dict["arguments"].split("[INFO] ")[1].split(" is now known as ")[0]
                newname = dict["arguments"].split("[INFO] ")[1].split(" is now known as ")[1].split(".")[0]
                remove_nick(oldname, buffer, group)
                add_nick(newname, buffer, group)
    return weechat.WEECHAT_RC_OK
Ejemplo n.º 4
0
def get_nick_group(buffer, group_name):
    group = w.nicklist_search_group(buffer, "", group_name)
    if not group:
        group = w.nicklist_add_group(buffer, "", group_name, "weechat.color.nicklist_group", 1)
    return group
Ejemplo n.º 5
0
def update_nicklist(buffer_name):
    buffer_pointer = weechat.buffer_search('irc', buffer_name)
    if not buffer_pointer:
        return

    group_pointers = {}

    infolist = weechat.infolist_get('nicklist', buffer_pointer, '')
    infolist_string = weechat.infolist_string
    infolist_next = weechat.infolist_next
    while infolist_next(infolist):
        if not infolist_string(infolist, 'type') == 'nick':
            continue

        nick = infolist_string(infolist, 'name')
        if nick not in ident_nick:
            continue
        
        group = infolist_string(infolist, 'group_name')
        color = infolist_string(infolist, 'color')
        prefix = infolist_string(infolist, 'prefix')
        prefix_color = infolist_string(infolist, 'prefix_color')

        if ident_nick[nick]:
            prefix_new = ' '
            group_new = '080|ident'
            color_new = 'green'
        else:
            prefix_new = '~'
            group_new = '081|unident'
            color_new = 'brown'
            prefix_color = 'cyan'

        if prefix[0] != prefix_new[0]:
            if prefix == ' ':
                prefix = prefix_new
                prefix_new = ''
            elif prefix_new != ' ':
                prefix = prefix_new + prefix
                prefix_new = ''

        if color == 'bar_fg':
            color = color_new
            color_new = ''

        if group[:2] == '08':
            group = group_new
            group_new = ''
            try:
                group_pointer = group_pointers[group]
            except KeyError:
                group_pointer = weechat.nicklist_search_group(buffer_pointer, '', group)
                if not group_pointer:
                    group_pointer = weechat.nicklist_add_group(buffer_pointer, '', group,
                            'weechat.color.nicklist_group', 1)
                group_pointers[group] = group_pointer
        else:
            group_pointer = weechat.nicklist_search_group(buffer_pointer, '', group)

        if prefix_new and group_new and color_new:
            # nothing to change
            continue

        #debug('adding nick: %s%s to %s' %(prefix, nick, group))
        nick_pointer = weechat.nicklist_search_nick(buffer_pointer, '', nick)
        if nick_pointer:
            weechat.nicklist_remove_nick(buffer_pointer, nick_pointer)
        nick_pointer = weechat.nicklist_add_nick(buffer_pointer, group_pointer, nick, color,
                prefix, prefix_color, 1)
        nicklist[buffer_name, nick] = (buffer_pointer, nick_pointer)
    weechat.infolist_free(infolist)
Ejemplo n.º 6
0
def get_nick_group(buffer, group_name):
    group = w.nicklist_search_group(buffer, "", group_name)
    if not group:
        group = w.nicklist_add_group(buffer, "", group_name,
                                     "weechat.color.nicklist_group", 1)
    return group
Ejemplo n.º 7
0
def buf_room_add(buf, nick, groupname=""):
	if weechat.nicklist_search_group(buf, "", "members") == "":
		weechat.nicklist_add_group(buf, "", "members", "weechat.color.nicklist_group", 1)
	nickbufp = weechat.nicklist_add_nick(buf, groupname, nick, "bar_fg", "", "bar_fg", 1)
	weechat.nicklist_nick_set(buf, nickbufp, "color", "white")
Ejemplo n.º 8
0
def set_colors( users_logged_in ):
	global rbon_messages								# Variable to hold contents of rbon bar item
	global first_run									# Script needs one run to populate online and offline dictionaries

	global online_dict
	global offline_dict
	global outgoing_list
	global incoming_list

	nicks = weechat.infolist_get( 'irc_nick', '', 'redbrick,#lobby' )
	buff_ptr = weechat.buffer_search( "irc","redbrick.#lobby" )
	if( nicks == "" and buff_ptr == "" ):
		nicks = weechat.infolist_get( 'irc_nick', '', 'irc.redbrick.dcu.ie,#lobby' )
		buff_ptr = weechat.buffer_search( "irc","irc.redbrick.dcu.ie.#lobby" )

	group_normal_ptr = weechat.nicklist_search_group( buff_ptr, "", "..." )
	group_op_ptr = weechat.nicklist_search_group( buff_ptr, "", "o" )
	color_nick_online = weechat.config_get_plugin( "color_nick_online" )
	if( nicks != None ):
		if( nicks == {} ):
			weechat.prnt( "No nicks" )
		else:
			while weechat.infolist_next( nicks ):										# Stepping through each nick in #lobby
				name = weechat.infolist_string(nicks, 'name')
				host = weechat.infolist_string(nicks, 'host')
				flag = weechat.infolist_integer(nicks, 'flags')
				timeout = int(weechat.config_get_plugin("interim_period"))
				if( "@Redbrick.dcu.ie" in host ):
					rnick = re.sub('@Redbrick.dcu.ie', '', host)						# Strip real nick from host
					nick_ptr = weechat.nicklist_search_nick(buff_ptr, "", name)         # Find nick pointer

					#
					# - Incoming/Outgoing lists won't be populated if at least one iteration of the list hasn't happened.
					#		first_run set false at the end of first iteration
					# - Set outgoing if - user is offline, user WAS online on the last iteration, user is not currently outgoing
					# - Set incoming if - user is online, user was NOT online on the last iteration, user is not currently incoming 
					#

					#
					# - Script uses stacks
					#		When user moves into a state they are pushed onto the stack
					#		After a set time hook_timer's callback pops the user off the stack and they are moved into either offline or online dictionary
					#

					# If NOT already logged in NOT first run WAS online on last loop NOT in outgoing list 

					if( not rnick in users_logged_in and not first_run and rnick in online_dict and rnick not in outgoing_list ):
						# weechat.prnt("", "OUTgoing user - %s" % rnick)
						outgoing_list.insert(0, rnick)
						weechat.hook_timer(timeout * 1000, 0, 1, "pop_outgoing", "")				# TODO - This hook executes pop_outgoing immediately instead of waiting 10 seconds
						color = weechat.config_get_plugin( "outgoing_color" )
						# TODO - Add OUTGOING nick to rbon_messages here to be displayed in the rbon bar item
						rbon_nick_color = weechat.color( color )
						string = "%s%s" % ( rbon_nick_color,name )

						rbon_messages.append( string )
						weechat.bar_item_update( "rbon" )

						if( rnick in online_dict ):
							del online_dict[ rnick ]

					# If IS logged in NOT first run IN nicklist WAS offline on last loop NOT in incoming list

					elif( rnick in users_logged_in and not first_run and rnick in offline_dict and rnick not in incoming_list ):
						# weechat.prnt("", "INcoming user - %s" % rnick)
						incoming_list.insert(0, rnick)
						weechat.hook_timer(timeout * 1000, 0, 1, "pop_incoming", "")				# TODO - This hook executes pop_incoming immediately instead of waiting 10 seconds
						color = weechat.config_get_plugin("incoming_color")												# Color incoming users red
						# TODO - Add INCOMING nick to rbon_messages here to be displayed in the rbon bar item
						rb_nick_color = weechat.color( color )	
						string = "%s%s" % ( rb_nick_color, name )
						
						rbon_messages.append( string )
						weechat.bar_item_update( "rbon" )

						if( rnick in offline_dict ):
							del offline_dict[rnick]

					elif( rnick in incoming_list ): color = weechat.config_get_plugin( "incoming_color" )

					elif( rnick in outgoing_list ): color = weechat.config_get_plugin( "outgoing_color" )

					# Check to see if that user is logged
					elif( rnick in users_logged_in ):
						if( rnick in offline_dict ):
							del offline_dict[rnick]
						online_dict[rnick] = ""
						color = weechat.config_get_plugin( "online_color" )												# Color online user user nicks

					else:
						offline_dict[rnick] = ""
						if( rnick in online_dict ):
							del online_dict[rnick]
						color = weechat.config_get_plugin( "offline_color" )											# Colour offline user nicks

					# Adding nicks with relevant colours back into the nicklist

					if( buff_ptr and nick_ptr ):
						# TODO - Decide whether or not this REMOVE should be moved...
						weechat.nicklist_remove_nick(buff_ptr, nick_ptr)
					if( buff_ptr ):															# The nick may already have been removed from the buffer....
						if( flag == 0 ):													# Check if normal user
							weechat.nicklist_add_nick(buff_ptr, group_normal_ptr, name, weechat.color(color), " ", color, 1)
						elif( flag == 8 ):													# Check if ops (include @ prefix) 
							weechat.nicklist_add_nick(buff_ptr, group_op_ptr, name, weechat.color(color), "@", color, 1)
	first_run = 0
	users_rb_dict.clear()
	weechat.infolist_free( nicks )
	return weechat.WEECHAT_RC_OK
Ejemplo n.º 9
0
def update_nicklist(buffer_name):
    buffer_pointer = weechat.buffer_search('irc', buffer_name)
    if not buffer_pointer:
        return

    group_pointers = {}

    infolist = weechat.infolist_get('nicklist', buffer_pointer, '')
    infolist_string = weechat.infolist_string
    infolist_next = weechat.infolist_next
    while infolist_next(infolist):
        if not infolist_string(infolist, 'type') == 'nick':
            continue

        nick = infolist_string(infolist, 'name')
        if nick not in ident_nick:
            continue

        group = infolist_string(infolist, 'group_name')
        color = infolist_string(infolist, 'color')
        prefix = infolist_string(infolist, 'prefix')
        prefix_color = infolist_string(infolist, 'prefix_color')

        if ident_nick[nick]:
            prefix_new = ' '
            group_new = '080|ident'
            color_new = 'green'
        else:
            prefix_new = '~'
            group_new = '081|unident'
            color_new = 'brown'
            prefix_color = 'cyan'

        if prefix[0] != prefix_new[0]:
            if prefix == ' ':
                prefix = prefix_new
                prefix_new = ''
            elif prefix_new != ' ':
                prefix = prefix_new + prefix
                prefix_new = ''

        if color == 'bar_fg':
            color = color_new
            color_new = ''

        if group[:2] == '08':
            group = group_new
            group_new = ''
            try:
                group_pointer = group_pointers[group]
            except KeyError:
                group_pointer = weechat.nicklist_search_group(
                    buffer_pointer, '', group)
                if not group_pointer:
                    group_pointer = weechat.nicklist_add_group(
                        buffer_pointer, '', group,
                        'weechat.color.nicklist_group', 1)
                group_pointers[group] = group_pointer
        else:
            group_pointer = weechat.nicklist_search_group(
                buffer_pointer, '', group)

        if prefix_new and group_new and color_new:
            # nothing to change
            continue

        #debug('adding nick: %s%s to %s' %(prefix, nick, group))
        nick_pointer = weechat.nicklist_search_nick(buffer_pointer, '', nick)
        if nick_pointer:
            weechat.nicklist_remove_nick(buffer_pointer, nick_pointer)
        nick_pointer = weechat.nicklist_add_nick(buffer_pointer, group_pointer,
                                                 nick, color, prefix,
                                                 prefix_color, 1)
        nicklist[buffer_name, nick] = (buffer_pointer, nick_pointer)
    weechat.infolist_free(infolist)