Esempio n. 1
0
            color = get_color(ctable,stuff.replace('\x02','').replace('\x0f','').replace('<','').replace('>','').lower())
            newnick = ecs('o') + col(color) + stuff.replace('\x02','').replace('\x0f','') + '\x0f'
            word[1] = word[1].replace(stuff, newnick)
        hexchat.emit_print(event_name, *word, time=attributes.time)
        return hexchat.EAT_ALL
    else:
        return hexchat.EAT_NONE


########## HOOK IT UP ###########

try:
    permacolortable = pickle.load(open(datafile))
except:
    pass

hexchat.hook_print_attrs("Channel Message", message_callback, "Channel Message", priority=hexchat.PRI_HIGHEST)
hexchat.hook_print_attrs("Channel Action", message_callback, "Channel Action", priority=hexchat.PRI_HIGHEST)

hexchat.hook_command("NICENICKS", nicenicks_command, None, hexchat.PRI_NORM,
                     "NICENICKS INFO:\t\nThis script will colourize nicks of users automatically, using a 'least-recently-used' algorithm (to avoid two people having the same colour).\n\nFriends' nicks can be assigned a specific colour with the SETCOLOR command, a list of colors can be shown with the COLORTABLE command, and this script can be enabled/disabled with the NICENICKS command (/NICENICKS on or /NICENICKS off).\n\nAlso, for fun, try '/NICENICKS_DUMP', or '/NICEDEBUG on'")
hexchat.hook_command("NICEDEBUG", nicedebug_command, None, hexchat.PRI_NORM,
                     "Usage:\t/NICEDEBUG On to enable, /NICEDEBUG Off to disable.")
hexchat.hook_command("SETCOLOR", setcolor_command, None, hexchat.PRI_NORM,
                     "Usage:\t/SETCOLOR -- show colour mappings\n/SETCOLOR [nick] [color] -- permanently maps [color] to [nick] (stealing the colour from other users if necessary)\n/SETCOLOR -[nick] -- remove [nick] from colour mapping table")
hexchat.hook_command("COLORTABLE", color_table_command)
hexchat.hook_command("NICENICKS_DUMP", nicenicks_dump_command, None, hexchat.PRI_NORM,
                     "Usage:\t/NICENICKS_DUMP to dump all the nick colours for all active channels")

omsg("Nicenicks version {} loaded!".format(__module_version__))
Esempio n. 2
0
    network = hexchat.get_info("network")
    channel = hexchat.get_info("channel")
    if network not in networks or channel not in networks[network]:
        pretty_print("Nothing to print.")
        return
    hexchat.command("clear")
    uids.clear()
    halt = True
    hooked = True
    for msg in networks[network][channel]:
        data = urlify(msg['event'], msg['data'], network, channel)
        hexchat.emit_print(msg['event'], *data, time=msg['time'])
    pretty_print("Hint to follow?")
    hint_hook = hexchat.hook_print("Key Press", open_url, (network, channel))
    halt = False
    return hexchat.EAT_ALL


hooks = ["Your Message", "Channel Message",
         "Channel Msg Hilight", "Your Action", "Channel Action",
         "Channel Action Hilight", "Join", "Change Nick", "Part",
         "Part with Reason", "Quit"]
for hook in hooks:
    hexchat.hook_print_attrs(hook, new_msg, hook, hexchat.PRI_LOWEST)
    hexchat.hook_print(hook, eat_event, hook, hexchat.PRI_HIGHEST)
hexchat.hook_print("Key Press", show_hints)

print("\00304", __module_name__, "successfully loaded.\003")


Esempio n. 3
0
import hexchat

__module_name__ = "Spagt Bridge"
__module_version__ = "0.1-AWSUM"
__module_description__ = "Changes how SpagtBridge's messages are displayed"


def chanmessage(word, word_eol, userdata, attr):
    nick = word[0]
    message = word[1]
    if (hexchat.nickcmp(hexchat.strip(nick), "S") == 0
            or hexchat.nickcmp(hexchat.strip(nick), "SpagtBridge")
            == 0) and message.startswith("<"):
        name = message[1:message.index('>')] + ":"
        message = message[message.index('>') + 2:]
        mode = name[1] if name[1] in "@+&~%" else ""

        hexchat.emit_print(userdata, name, message, mode, time=attr.time)
        return hexchat.EAT_ALL
    return hexchat.EAT_NONE


hexchat.hook_print_attrs("Channel Message", chanmessage, "Channel Message")
hexchat.hook_print_attrs("Channel Msg Hilight", chanmessage,
                         "Channel Msg Hilight")
hexchat.hook_print_attrs("Channel Action", chanmessage, "Channel Action")
hexchat.hook_print_attrs("Channel Action Hilight", chanmessage,
                         "Channel Action Hilight")
Esempio n. 4
0
        hexchat.emit_print(event_name, *word, time=attributes.time)
        hexchat.command("gui color 2")  # required since HexChat 2.12.4
        return hexchat.EAT_ALL
    else:
        return hexchat.EAT_NONE


########## HOOK IT UP ###########

try:
    permacolortable = pickle.load(open(datafile, "rb"))
except:
    pass

hexchat.hook_print_attrs("Channel Message",
                         message_callback,
                         "Channel Message",
                         priority=hexchat.PRI_HIGHEST)
hexchat.hook_print_attrs("Channel Action",
                         message_callback,
                         "Channel Action",
                         priority=hexchat.PRI_HIGHEST)

hexchat.hook_command(
    "NICENICKS", nicenicks_command, None, hexchat.PRI_NORM,
    "NICENICKS INFO:\t\nThis script will colourize nicks of users automatically, using a 'least-recently-used' algorithm (to avoid two people having the same colour).\n\nFriends' nicks can be assigned a specific colour with the SETCOLOR command, a list of colors can be shown with the COLORTABLE command, and this script can be enabled/disabled with the NICENICKS command (/NICENICKS on or /NICENICKS off).\n\nAlso, for fun, try '/NICENICKS_DUMP', or '/NICEDEBUG on'"
)
hexchat.hook_command(
    "NICEDEBUG", nicedebug_command, None, hexchat.PRI_NORM,
    "Usage:\t/NICEDEBUG On to enable, /NICEDEBUG Off to disable.")
hexchat.hook_command(
    "SETCOLOR", setcolor_command, None, hexchat.PRI_NORM,
Esempio n. 5
0
 def decorator(func):
     wrapper = Wrapper(func, on_error)
     hookid = hexchat.hook_print_attrs(cmd, wrapper, userdata, priority)
     wrapper.set_hook(hookid)
     return wrapper
Esempio n. 6
0

def connection(word, word_eol, userdata, attributes):
    """
    Display all messages at once 5 seconds after a connection.

    That way, messages can be sorted by time instead of
    having all from one channel, then all from another, etc.
    """
    global waiting
    waiting += 1
    hexchat.command('timer 5 backlog')


# Get last hilight (so we don't print hls already seen from backlogs)
previous_session_last_hl = hexchat.get_pluginpref(PREF)
if previous_session_last_hl:
    previous_session_last_hl = int(previous_session_last_hl)
    last_hl = previous_session_last_hl
else:
    previous_session_last_hl = 0
    last_hl = 0

hexchat.hook_print_attrs('Channel Msg Hilight', message)
hexchat.hook_print_attrs('Channel Action Hilight', message)
hexchat.hook_command('backlog', forcePrint)
# 376: RPL_ENDOFMOTD (just before starting receiving backlogs if any)
hexchat.hook_server_attrs('376', connection)

print('%s\tLoaded' % __module_name__)
Esempio n. 7
0
__module_name__ = 'Splitter'
__module_version__ = '0.3'
__module_description__ = 'Cleans up net split messages'
 
import hexchat
from time import time
 
split_timeout = 2 #time before split resets
last_split = time()
 
def split_finder(word, word_eol, event, attrs):
	
	global last_split
	reason = hexchat.strip(word[1])
	if reason == "*.net *.split":
		if time() - last_split > split_timeout:
			print("\00304IT'S A NET SPLIT!! RUN FOR THE HILLS")
			last_split = time()
		return hexchat.EAT_ALL
		
hook = "Quit"
hexchat.hook_print_attrs(hook, split_finder, hook, hexchat.PRI_HIGH)
print("\00304" + __module_name__ + " successfully loaded.\003")
Esempio n. 8
0
File: qc.py Progetto: SoniEx2/Stuff
                                targetfmt = parse(reason, True, format)-format
                                fmtstr = str(targetfmt)
                                reason = reason + fmtstr
                    else:
                        format = format + obj

            if attributes.time:
                ctx.emit_print("Kick", qc_host, compress_colors(nick), ctx.get_info("channel"), reason,
                    time=attributes.time)
            else:
                ctx.emit_print("Kick", qc_host, compress_colors(nick), ctx.get_info("channel"), reason)
            return hexchat.EAT_ALL
    return hexchat.EAT_NONE

# Message/action hooks
hexchat.hook_print_attrs("Channel Message", qcbot_msg, userdata=["Channel Message", qc_msg_mask])
hexchat.hook_print_attrs("Channel Msg Hilight", qcbot_msg, userdata=["Channel Msg Hilight", qc_msg_mask])
hexchat.hook_print_attrs("Channel Message", qcbot_msg, userdata=["Channel Action", qc_action_mask])
hexchat.hook_print_attrs("Channel Msg Hilight", qcbot_msg, userdata=["Channel Action Hilight", qc_action_mask])

# Connect/disconnect hooks
hexchat.hook_print_attrs("Channel Message", qcbot_connect)
hexchat.hook_print_attrs("Channel Msg Hilight", qcbot_connect)
hexchat.hook_print_attrs("Channel Message", qcbot_disconnect)
hexchat.hook_print_attrs("Channel Msg Hilight", qcbot_disconnect)

# kick
hexchat.hook_print_attrs("Channel Message", qcbot_kick)
hexchat.hook_print_attrs("Channel Msg Hilight", qcbot_kick)

Esempio n. 9
0
	# Different date
	if event.year < now.year or event.month < now.month or event.day < now.day:
		return False

	return True

def msg_cb(word, word_eol, event_name, attrs):
	global edited

	if edited or is_today(attrs.time):
		return

	format = hexchat.get_prefs('stamp_text_format')
	hexchat.command('set -quiet stamp_text_format {}'.format('%m-%d ' + format))

	edited = True
	hexchat.emit_print(event_name, word[0], word[1], time=attrs.time)
	edited = False

	hexchat.command('set -quiet stamp_text_format {}'.format(format))

	return hexchat.EAT_ALL

def unload_cb(userdata):
	print(__module_name__, 'version', __module_version__, 'unloaded.')

for event in events:
	hexchat.hook_print_attrs(event, msg_cb, event)
hexchat.hook_unload(unload_cb)
print(__module_name__, 'version', __module_version__, 'loaded.')
Esempio n. 10
0
halt = False

#channel is nick
def test(word, word_eol, event, attrs):

    global halt
    if halt:
        return

    code = ""
    message = word[1]
    #message.replace("\x03","\\003")
    if "Hilight" in event:
        code = "19"
    elif "Your" in event:
        code = "30"
    message = re.sub(r'(?<=\x03)' + '(?![0-9])', code, message)
    word[1] = message
    halt = True
    hexchat.emit_print(event, *word)
    halt = False
    return hexchat.EAT_ALL

hooks = ["Your Message", "Channel Message", "Channel Msg Hilight", "Your Action", "Channel Action", "Channel Action Hilight"]

for hook in hooks:
	hexchat.hook_print_attrs(hook, test, hook, hexchat.PRI_LOW)

print("\00304" + __module_name__ + " successfully loaded.\003")
Esempio n. 11
0
__module_description__ = 'Colors nicks based on user mode'
# This is just a direct port of LifeIsPain's statuscolor.pl script.

events = ('Channel Message', 'Channel Action', 'Channel Msg Hilight',
          'Channel Action Hilight', 'Your Message', 'Your Action')

# TODO: update these for hexchats default theme
modes = {'+': '24', '%': '28', '@': '19', '&': '21', '~': '22'}

edited = False


def msg_cb(word, word_eol, event, attrs):
    global edited
    if edited or len(word) < 3 or not word[2] in modes:
        return hexchat.EAT_NONE

    color = modes[word[2]]
    nick = '\003{}{}\00399'.format(color, hexchat.strip(word[0]))
    word = [(word[i] if len(word) > i else '') for i in range(4)]

    edited = True
    hexchat.emit_print(event, nick, word[1], word[2], word[3], time=attrs.time)
    edited = False

    return hexchat.EAT_ALL


for event in events:
    hexchat.hook_print_attrs(event, msg_cb, event, hexchat.PRI_HIGH)
    'dynimc',
    'ingameinfo',
    'msh',
    'profiles',
    'schematica',
    'stackie',
]

whitelist = [thing.lower() for thing in whitelist]


def print_cb(word, word_eol, userdata, attrs):
    sender = word[0]
    msg = word[1].lower()

    if sender != 'MissOpenEye' or hexchat.get_info('channel') != '#OpenEye':
        return hexchat.EAT_NONE

    for thing in whitelist:
        if msg.find(thing) != -1:
            return hexchat.EAT_NONE

    if msg.find('\x0304\x02\x1fcrash') != -1 or msg.find('\x0303\x02\x1ffiles') != -1:
        return hexchat.EAT_ALL

    return hexchat.EAT_NONE


hexchat.hook_print_attrs('Channel Message', print_cb)
hexchat.prnt('%s version %s loaded.' % (__module_name__, __module_version__))
Esempio n. 13
0
    return True


def msg_cb(word, word_eol, event_name, attrs):
    global edited

    if edited or is_today(attrs.time):
        return

    format = hexchat.get_prefs('stamp_text_format')
    hexchat.command('set -quiet stamp_text_format {}'.format('%m-%d ' +
                                                             format))

    edited = True
    hexchat.emit_print(event_name, word[0], word[1], time=attrs.time)
    edited = False

    hexchat.command('set -quiet stamp_text_format {}'.format(format))

    return hexchat.EAT_ALL


def unload_cb(userdata):
    print(__module_name__, 'version', __module_version__, 'unloaded.')


for event in events:
    hexchat.hook_print_attrs(event, msg_cb, event)
hexchat.hook_unload(unload_cb)
print(__module_name__, 'version', __module_version__, 'loaded.')
Esempio n. 14
0
	return hexchat.EAT_ALL
	
#get colour for name
def get_colour(name):
	
	global colours
	raw = list(name)
	total = 0
	for ch in raw:
		total += ord(ch)
	return colours[total % len(colours)]

def name_search(text, name):
	
	global name_start, name_other
	m = re.search(r'(^|[^' + name_start + '])' + name + '($|[^' + name_other + '])', text)
	return m

#format the name text to avoid regex errors
def format_name(name):
	return name.replace('\\','\\\\').replace('|','\|').replace('^','\^').replace('[','\[').replace(']','\]')
	

#events to colour text
hooks = ["Your Message", "Channel Message", "Channel Msg Hilight", "Your Action", "Channel Action", "Channel Action Hilight"]

for hook in hooks:
	hexchat.hook_print_attrs(hook, colour_names, hook, hexchat.PRI_HIGH)

print("\00304" + __module_name__ + " successfully loaded.\003")
Esempio n. 15
0
            debugPartReasP = False

        if debugPartReasP:
            self.debugPrint("debugPartReasP: " + word_eol[0])
            self.debugPrint("attribs:    " + repr(attribs))

        return hexchat.EAT_NONE


# make an object of the class which contains all of the above funcs as methods
irc_subst_obj = irc_subst(pathname)

# establish the hook to the input method, immediately above
hexchat.hook_command('', irc_subst_obj.inputHook)

# establish the hook to the notice method of irc_subst, above
hexchat.hook_server('NOTICE', irc_subst_obj.notice_hook)

# establish the hook to the join_hook method of irc_subst, above
hexchat.hook_print_attrs('Join', irc_subst_obj.join_hook)

# establish the hooks to the part_hook and partreas_hook methods of irc_subst, above
hexchat.hook_print_attrs('Part', irc_subst_obj.part_hook)
hexchat.hook_print_attrs('Part with Reason', irc_subst_obj.partreas_hook)

# establish for channel, and for private, messages
hexchat.hook_print_attrs('Channel Message', irc_subst_obj.channel_msg_hook)
hexchat.hook_print_attrs('Private Message', irc_subst_obj.private_msg_hook)
hexchat.hook_print_attrs('Private Message to Dialog',
                         irc_subst_obj.private_dialog_msg_hook)
Esempio n. 16
0
import hexchat

__module_name__ = "debug"
__module_author__ = "jim"
__module_version__ = "0.1"
__module_descritption = "shows all the callback params"

# this function, to be hooked to the "Channel Message" event, is
# for the purpose of looking at the event information, doesn't
# do anything else, and because it returns EAT_NONE, hexchat will
# handle the event as normal.


def readMessage(word, word_eol, userdata, attribs):
    print("word: " + repr(word))
    print("word_eol: " + repr(word_eol))
    print("userdata: " + repr(userdata))
    print("attribs: " + repr(attribs))

    return hexchat.EAT_NONE


hexchat.hook_print_attrs('Channel Message', readMessage)
def my_msg_cb(word, word_eol, _):
    """Add "@" before nicks sourced from discord."""
    channel = hexchat.get_info('channel')
    if channel not in BOT_MAP:
        return hexchat.EAT_NONE

    discord_nicks = {user.nick for user in hexchat.get_list('users')
                     if user.host == "*****@*****.**"}
    if not discord_nicks:
        return hexchat.EAT_NONE

    nick_regex = r"\b(?<!@)({})\b".format("|".join(map(re.escape, discord_nicks)))
    original_text = word_eol[0]

    text = re.sub(nick_regex, r"@\1", original_text)
    if text == original_text:
        return hexchat.EAT_NONE
    else:
        hexchat.command("SAY {}".format(text))
        return hexchat.EAT_ALL


if __name__ == '__main__':
    for event in ('Channel Message', 'Channel Msg Hilight',
                  'Channel Action', 'Channel Action Hilight'):
        hexchat.hook_print_attrs(event, msg_cb, event, hexchat.PRI_HIGHEST)

    hexchat.hook_command('', my_msg_cb)

    print(__module_name__, __module_version__, "loaded")
Esempio n. 18
0
 def decorator(func):
     wrapper = Wrapper(func, on_error)
     hookid = hexchat.hook_print_attrs(cmd, wrapper, userdata, priority)
     wrapper.set_hook(hookid)
     return wrapper
Esempio n. 19
0
__module_description__ = 'Highlights URLs'

beforeHL = '\037\00320'
afterHL = '\00399\037'
url_regex = '(.*?)(http(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*?(:(0-9)*)*?(\/?)([a-zA-Z0-9\-‌​\.\?\,\'\/\\\+&amp;%\$#_]*)?)(.*)'

edited = False

def print_cb(word, word_eol, event, attr):
    global edited
    # Ignore our own events, bouncer playback, empty messages
    if edited or attr.time or not len(word) > 1:
        return

    msg = word[1]
    if re.compile(url_regex).match(msg):
        msg = re.sub(url_regex, "\\1" + beforeHL + "\\2" + afterHL + "\\9", msg).strip()

        edited = True
        hexchat.emit_print(event, word[0], msg)
        edited = False

        return hexchat.EAT_HEXCHAT

events = ("Channel Message", "Channel Action",
          "Channel Msg Hilight", "Channel Action Hilight",
          "Private Message", "Private Action")
          
for hook in events:
    hexchat.hook_print_attrs(hook, print_cb, hook, priority=hexchat.PRI_LOW)
Esempio n. 20
0
        user = hexchat.strip(word[1])
        old = hexchat.strip(word[0])
        if old in last_seen:
            last_seen[user] = last_seen[old]
            del last_seen[old]
        else:
            last_seen[user] = [time(), 0]
    # If the user logged in before we did (no entry of him yet), don't display
    # his part messages
    if user not in last_seen:
        return hexchat.EAT_ALL
    # If the user has never spoken, or has spoken too long ago, eat his part
    # or join messages.
    if last_seen[user][1] == 0 or last_seen[user][0] + user_timeout < time():
        return hexchat.EAT_ALL


hooks_new = [
    "Your Message", "Channel Message", "Channel Msg Hilight", "Your Action",
    "Channel Action", "Channel Action Hilight"
]
hooks_filter = ["Join", "Change Nick", "Part", "Part with Reason", "Quit"]
# hook_print_attrs is used for compatibility with my other scripts,
# since priorities are hook specific
for hook in hooks_new:
    hexchat.hook_print_attrs(hook, new_msg, hook, hexchat.PRI_HIGH)
for hook in hooks_filter:
    hexchat.hook_print_attrs(hook, filter_msg, hook, hexchat.PRI_HIGH)

print("\00304", __module_name__, "successfully loaded.\003")
def message(word, word_eol, userdata, attributes):
    global edited
    if (edited):
        return

    nick = word[0]
    msg = word[1]
    mode = word[2] if len(word) == 3 else ''

    for u in filter(lambda u: u.nick in msg,
                    hexchat.get_context().get_list('users')):
        msg = re.sub(r'(?<![/\u200b.])@?\b%s\b' % re.escape(u.nick),
                     FORMAT % (u.prefix, COLOR % nick_color(u.nick), u.nick),
                     msg)

    edited = True
    hexchat.emit_print(userdata, nick, msg, mode, time=attributes.time)
    edited = False
    return hexchat.EAT_ALL


events = [
    'Channel Action', 'Channel Message', 'Channel Msg Hilight',
    'Channel Action Hilight', 'Your Message', 'Your Action'
]
for e in events:
    hexchat.hook_print_attrs(e, message, priority=hexchat.PRI_HIGH, userdata=e)

print('%s\tLoaded' % __module_name__)
Esempio n. 22
0
    #word[1] = "\002\026{0}{1}".format(col(color), word[1])
    word[1] = "\002\026{0}{1}".format(col(color), word[1])
    dmsg('Old nick: %s - New Nick: %s' % (nick, newnick))
    hexchat.emit_print(event_name, *word, time=attributes.time)
    #hexchat.emit_print(event_name, "\002\026{0}{1}".format(color, word_eol))
    if not is_color3_tab(ctx):
        hexchat.command("gui color 2")  # required since HexChat 2.12.4
    return hexchat.EAT_ALL


########## HOOK IT UP ###########

load_config()

hexchat.hook_print_attrs("Channel Message",
                         message_callback,
                         "Channel Message",
                         priority=hexchat.PRI_HIGHEST)
hexchat.hook_print_attrs("Channel Action",
                         message_callback,
                         "Channel Action",
                         priority=hexchat.PRI_HIGHEST)
hexchat.hook_print_attrs("Channel Msg Hilight",
                         tab_hilight_callback,
                         priority=hexchat.PRI_LOW)
hexchat.hook_print_attrs("Channel Action Hilight",
                         tab_hilight_callback,
                         priority=hexchat.PRI_LOW)

hexchat.hook_command(
    "PLAYBYCHAT", playbychat_command, None, hexchat.PRI_NORM,
    "PLAYBYCHAT INFO:\t\nThis script will colourize nicks of users automatically, using a 'least-recently-used' algorithm (to avoid two people having the same colour).\n\nFriends' nicks can be assigned a specific colour with the SETCOLOR command, a list of colours can be shown with the COLORTABLE command, and this script can be enabled/disabled with the PLAYBYCHAT command (/PLAYBYCHAT on or /PLAYBYCHAT off).\n\nAlso '/NICEDEBUG on'"
Esempio n. 23
0
        if eat:
            jmap.add(nick, attrs.time or int(time.time()), word)
        return eat


def part_cb(word, word_eol, userdata):
    nick = hexchat.strip(word[0])
    if check_notify(nick):
        return hexchat.EAT_NONE
    # do not pop from tmap (in case user rejoins)
    jmap.pop(nick)

    return check_lasttalk(word[0])

if __name__ == '__main__':
    for event in ('Quit', 'Part', 'Part with Reason'):
        hexchat.hook_print(event, part_cb)
    for event in ('Channel Operator', 'Channel Voice', 'Channel Half-Operator'):
        hexchat.hook_print(event, mode_cb)
    for event in ('Channel Action', 'Channel Action Hilight',
                  'Channel Message', 'Channel Message Hilight'):
        hexchat.hook_print_attrs(event, msg_cb, event)
    hexchat.hook_print('Raw Modes', raw_mode_cb)
    hexchat.hook_print_attrs('Join', join_cb)
    hexchat.hook_print('Change Nick', nick_cb)

    hexchat.hook_timer(CLEAN_INTERVAL * 1000, lambda x: jmap.clean())
    hexchat.hook_timer(CLEAN_INTERVAL * 1000, lambda x: tmap.clean())

    print(__module_name__, __module_version__, "loaded")
Esempio n. 24
0
    hexchat.emit_print(
        'Generic Message',
        MSG_HEADER % (mode, nick_color(nick), nick),
        MSG_FORMAT % msg,
        time = time
    )

def printAction(mode, nick, msg, time):
    color = nick_color(nick)
    hexchat.emit_print(
        'Generic Message',
        ACTION_HEADER % color,
        ACTION_FORMAT % (mode, color, nick, msg),
        time = time
    )

def message(word, word_eol, userdata, attributes):
    nick = word[0]
    msg  = word[1].replace(ITALIC, '').replace(RESET, RESET + ITALIC)
    mode = word[2] if len(word) == 3 else ''
    fct = printAction if userdata else printMessage
    fct(mode, nick, msg, attributes.time)

    return hexchat.EAT_HEXCHAT


hexchat.hook_print_attrs('Channel Msg Hilight', message, priority = hexchat.PRI_LOWEST)
hexchat.hook_print_attrs('Channel Action Hilight', message, priority = hexchat.PRI_LOWEST, userdata = True)

print('%s\tLoaded' % __module_name__)
Esempio n. 25
0
# When you want to notice something, but not really get 'highlighted'

# Case insensitive words
hlwords = ('hexchat', )

# Don't touch
edited = False

def print_cb(word, word_eol, event, attr):
	global edited
	# Ignore our own events, bouncer playback, empty messages
	if edited or attr.time or not len(word) > 1:
		return

	msg = word[1]
	for _word in hlwords:
		# Color red
		msg = re.sub(_word, '\00320' + _word + '\00399', msg, flags=re.I)

	if msg != word[1]: # Something replaced
		edited = True
		word = [(word[i] if len(word) > i else '') for i in range(4)]
		hexchat.emit_print(event, word[0], msg, word[2], word[3])
		edited = False

		hexchat.command('gui color 3')
		return hexchat.EAT_ALL

hexchat.hook_print_attrs('Channel Message', print_cb, 'Channel Message', priority=hexchat.PRI_HIGH)
hexchat.hook_print_attrs('Channel Action', print_cb, 'Channel Action', priority=hexchat.PRI_HIGH)
Esempio n. 26
0
    #elif 'Nick' in userdata:
    elif event == "Change Nick":
        user = hexchat.strip(word[1])
        old = hexchat.strip(word[0])
        if old in last_seen:
            last_seen[user] = last_seen[old]
            del last_seen[old]
        else:
            last_seen[user] = [time(), 0]
    # If the user logged in before we did (no entry of him yet), don't display
    # his part messages
    if user not in last_seen:
        return hexchat.EAT_ALL
    # If the user has never spoken, or has spoken too long ago, eat his part
    # or join messages.
    if last_seen[user][1] == 0 or last_seen[user][0] + user_timeout < time():
        return hexchat.EAT_ALL


hooks_new = ["Your Message", "Channel Message", "Channel Msg Hilight",
             "Your Action", "Channel Action", "Channel Action Hilight"]
hooks_filter = ["Join", "Change Nick", "Part", "Part with Reason", "Quit"]
# hook_print_attrs is used for compatibility with my other scripts,
# since priorities are hook specific
for hook in hooks_new:
    hexchat.hook_print_attrs(hook, new_msg, hook, hexchat.PRI_HIGH)
for hook in hooks_filter:
    hexchat.hook_print_attrs(hook, filter_msg, hook, hexchat.PRI_HIGH)

print("\00304", __module_name__, "successfully loaded.\003")
Esempio n. 27
0
File: qc.py Progetto: SoniEx2/Stuff
                ctx.emit_print("Kick",
                               qc_host,
                               compress_colors(nick),
                               ctx.get_info("channel"),
                               reason,
                               time=attributes.time)
            else:
                ctx.emit_print("Kick", qc_host, compress_colors(nick),
                               ctx.get_info("channel"), reason)
            return hexchat.EAT_ALL
    return hexchat.EAT_NONE


# Message/action hooks
hexchat.hook_print_attrs("Channel Message",
                         qcbot_msg,
                         userdata=["Channel Message", qc_msg_mask])
hexchat.hook_print_attrs("Channel Msg Hilight",
                         qcbot_msg,
                         userdata=["Channel Msg Hilight", qc_msg_mask])
hexchat.hook_print_attrs("Channel Message",
                         qcbot_msg,
                         userdata=["Channel Action", qc_action_mask])
hexchat.hook_print_attrs("Channel Msg Hilight",
                         qcbot_msg,
                         userdata=["Channel Action Hilight", qc_action_mask])

# Connect/disconnect hooks
hexchat.hook_print_attrs("Channel Message", qcbot_connect)
hexchat.hook_print_attrs("Channel Msg Hilight", qcbot_connect)
hexchat.hook_print_attrs("Channel Message", qcbot_disconnect)
Esempio n. 28
0
        else:
            debugPartReasP = False

        if debugPartReasP:
            self.debugPrint("debugPartReasP: " + word_eol[0])
            self.debugPrint("attribs:    " + repr(attribs))

        return hexchat.EAT_NONE


# make an object of the class which contains all of the above funcs as methods
irc_subst_obj = irc_subst(pathname)

# establish the hook to the input method, immediately above
hexchat.hook_command('', irc_subst_obj.inputHook)

# establish the hook to the notice method of irc_subst, above
hexchat.hook_server('NOTICE', irc_subst_obj.notice_hook)

# establish the hook to the join_hook method of irc_subst, above
hexchat.hook_print_attrs('Join', irc_subst_obj.join_hook)

# establish the hooks to the part_hook and partreas_hook methods of irc_subst, above
hexchat.hook_print_attrs('Part', irc_subst_obj.part_hook)
hexchat.hook_print_attrs('Part with Reason', irc_subst_obj.partreas_hook)

# establish for channel, and for private, messages
hexchat.hook_print_attrs('Channel Message', irc_subst_obj.channel_msg_hook)
hexchat.hook_print_attrs('Private Message', irc_subst_obj.private_msg_hook)
hexchat.hook_print_attrs('Private Message to Dialog', irc_subst_obj.private_dialog_msg_hook)
Esempio n. 29
0
def event_cb(word, word_eol, userdata, attr):
    # ignore znc playback
    if attr.time:
        return

    word = [(word[i] if len(word) > i else '') for i in range(4)]
    cur_context = hexchat.get_context()
    chan = cur_context.get_info('channel')

    for w in word[1].split():
        stripped_word = hexchat.strip(w, -1, 3)

        url = stripped_word

        if url.endswith(','):
            url = url[:-1]

        threading.Thread(target=print_title,
                         args=(url, chan, word[0], word[2],
                               cur_context)).start()

    return hexchat.EAT_NONE


for event in events:
    hexchat.hook_print_attrs(event, event_cb)

hexchat.prnt('Loaded ' + __module_name__ + ' ' + __module_version__ + ' by ' +
             __module_author__ + '. ' + __module_description__)
Esempio n. 30
0
                enchoded = "{} {}".format(history,
                                          message) if history else message
                dechoded, _ = choder.dechode(enchoded)
                formatted = RE_cocks.sub(dechoded, word[1])
                del buffer[word[0]]
                hexchat.emit_print("Channel Message", nick_format % word[0],
                                   formatted, "")
                return hexchat.EAT_HEXCHAT
        else:
            buffer[word[0]] = "{} {}".format(history,
                                             message) if history else message
            return hexchat.EAT_HEXCHAT


for event in events:
    hexchat.hook_print_attrs(event, choder_cb)


def enchode_cb(word, word_eol, userdata):
    input = word_eol[1][:150]
    s = choder.enchode(input, 2, 340)
    buffer["input"] = s.splitlines()
    for dongs in buffer["input"]:
        hexchat.get_context().command('say ' + dongs)
    del buffer["input"]
    hexchat.emit_print("Channel Message",
                       nick_format % hexchat.get_info('nick'), input, "")

    return hexchat.EAT_HEXCHAT

                        mode_target = targets[0]
                        del targets[0]

                    else:
                        mode_target = hexchat.get_info("channel")

                    if mode_char in modes:
                        hexchat.emit_print(modes[mode_char],
                                           setter,
                                           mode_target,
                                           time=attributes.time)

                    else:
                        hexchat.emit_print("Channel Mode Generic",
                                           setter,
                                           mode_sign,
                                           char,
                                           mode_target,
                                           time=attributes.time)

        return hexchat.EAT_HEXCHAT


# Make a hook that calls buffextras_msg when receiving a channel message or a highlight
hexchat.hook_print_attrs("Channel Message", buffextras_msg)
hexchat.hook_print_attrs("Channel Msg Hilight", buffextras_msg)
hexchat.hook_unload(unload)

# Print a message saying that the script was loaded
print(__module_name__ + " plugin loaded")
Esempio n. 32
0
    except urllib3.exceptions.HTTPError as e:
        print("\002Link Title:\002 {0}".format(e))


def event_cb(word, word_eol, userdata, attr):
    # ignore znc playback
    if attr.time:
        return

    word = [(word[i] if len(word) > i else "") for i in range(4)]
    chan = hexchat.get_info("channel")

    for w in word[1].split():
        stripped_word = hexchat.strip(w, -1, 3)

        if find_yt_script().match(stripped_word):
            url = stripped_word

            if url.endswith(","):
                url = url[:-1]

            threading.Thread(target=print_title, args=(url, chan, word[0], word[2])).start()

    return hexchat.EAT_NONE


for event in events:
    hexchat.hook_print_attrs(event, event_cb)

hexchat.prnt(__module_name__ + " version " + __module_version__ + " loaded")
Esempio n. 33
0
#         return '#%02x%02x%02x' % rgb

def returnHex(nick):
    random.seed(nick)
    return colours[random.randint(0,len(colours)-1)]


def print_cb(word, word_eol, event, attr):
    global edited
    if edited:
        return

    msg = word[1]
    nick = hexchat.strip(word[0])

    edited = True
    try:
        prefix = word[2]
    except IndexError:
        prefix = ""
    hexchat.emit_print(event, "\003"+returnHex(nick)+nick, msg, prefix)
    edited = False

    return hexchat.EAT_ALL

hexchat.hook_print_attrs('Channel Message', print_cb, 'Channel Message', priority=hexchat.PRI_NORM)
hexchat.hook_print_attrs('Channel Action', print_cb, 'Channel Action', priority=hexchat.PRI_NORM)
hexchat.hook_print_attrs('Private Message to Dialog', print_cb, 'Channel Message', priority=hexchat.PRI_NORM)
hexchat.hook_print_attrs('Private Action to Dialog', print_cb, 'Channel Action', priority=hexchat.PRI_NORM)

Esempio n. 34
0
__module_name__ = 'wordhl'
__module_author__ = 'TingPing'
__module_version__ = '1'
__module_description__ = 'Highlights some words of importance'
# When you want to notice something, but not really get 'highlighted'

hlwords = ('hexchat', )
edited = False

def print_cb(word, word_eol, event, attr):
	global edited
	# Ignore our own events, bouncer playback, empty messages
	if edited or attr.time or not len(word) > 1:
		return

	if any(_word in word[1] for _word in hlwords):
		msg = word[1]
		for _word in hlwords:
			msg = msg.replace(_word, '\00320' + _word + '\00399').strip() # Color red

		edited = True
		hexchat.emit_print(event, word[0], msg)
		edited = False

		hexchat.command('gui color 3')
		return hexchat.EAT_ALL

hexchat.hook_print_attrs('Channel Message', print_cb, 'Channel Message', priority=hexchat.PRI_HIGH)
hexchat.hook_print_attrs('Channel Action', print_cb, 'Channel Action', priority=hexchat.PRI_HIGH)
Esempio n. 35
0
import hexchat

__module_name__ = "Spigot Bridge"
__module_version__ = "0.1"
__module_description__ = "Changes how BridgeBabe's messages are displayed"

def chanmessage(word, word_eol, userdata, attr):
	nick = word[0]
	message = word[1]
	if (hexchat.nickcmp(hexchat.strip(nick), "B") == 0 or hexchat.nickcmp(hexchat.strip(nick), "BridgeBabe") == 0) and message.startswith("("):		
		name = "." + message[1:message.index(')')]
		message = message[message.index(')') + 2:]
		mode = name[1] if name[1] in "@+&~%" else ""

		hexchat.emit_print(userdata, name, message, mode, time = attr.time)
		return hexchat.EAT_ALL
	return hexchat.EAT_NONE

hexchat.hook_print_attrs("Channel Message", chanmessage, "Channel Message")
hexchat.hook_print_attrs("Channel Msg Hilight", chanmessage, "Channel Msg Hilight")
hexchat.hook_print_attrs("Channel Action", chanmessage, "Channel Action")
hexchat.hook_print_attrs("Channel Action Hilight", chanmessage, "Channel Action Hilight")
Esempio n. 36
0
__module_name__ = 'Slacker'
__module_version__ = '0.1'
__module_description__ = 'Slack cleanup script'

import hexchat
from time import time
# hooks: "Channel DeVoice", "Channel Voice"
# emots: :grinning::grin::joy::smiley::smile::sweat_smile::satisfied::innocent::smiling_imp::wink::blush::yum::relieved::heart_eyes::sunglasses::smirk::neutral_face::expressionless::unamused::sweat::pensive:
#get's rid of voice notifications
def voice(word, word_eol, event, attrs):
	server = hexchat.get_info("network")
	if server == "Slack":
		return hexchat.EAT_ALL

hooks_voice = ["Channel DeVoice", "Channel Voice"]
for hook in hooks_voice:
	hexchat.hook_print_attrs(hook, voice, hook, hexchat.PRI_HIGH)
	
print("\00304" + __module_name__ + " successfully loaded.\003")
Esempio n. 37
0
                hexchat.command("os akill add %s *@%s %s" % (akill_time,str(connecting_ip),akill_reason))           

        return hexchat.EAT_ALL  

    def xline_timeout_cb(_):
        xline_unhook()

    xline_hooks = [hexchat.hook_server(numeric, xline_notice_cb) for numeric in numerics]   
    xline_timer_handle = hexchat.hook_timer(1000, xline_timeout_cb)

    return hexchat.EAT_ALL
hexchat.hook_command("xline", xline_cb, help="/xline <nick> , Akills user from the server.")
hexchat.hook_command("xshun", xshun_cb, help="/xshun <nick> , Shuns user from the server.")
hexchat.hook_command("xsqline", xsqline, help="/xsqline <nick> , Places an sqline on the nick")
hexchat.hook_print("Server Notice", on_server_join)
hexchat.hook_print_attrs("Join", on_chan_join, "Join",priority=hexchat.PRI_NORM)
hexchat.hook_print_attrs("Channel Ban", on_chan_ban, "Channel Ban",priority=hexchat.PRI_NORM)
hexchat.hook_print_attrs("Channel UnBan", on_chan_unban, "Channel UnBan",priority=hexchat.PRI_NORM)
print(__module_version__ + " version " + __module_name__ + " loaded.")
            



'''
TODO

Add keyboard shortcuts inside this plugin if possible.
Move GeoIP checking to a local DB instead of using a web API.
Add country to whois info

'''