示例#1
0
def autoinvite_callback(word, word_eol, user_data):
	channel = word[0]
	
	def invited_callback(word, word_eol, user_data):
		invited_result = hexchat.EAT_NONE
		
		if word[0] == channel:
			hexchat.unhook(invited_hook)
			hexchat.unhook(denied_hook)
			invited_result = hexchat.EAT_HEXCHAT
			hexchat.command('join {0}'.format(channel))
		
		return invited_result
	
	invited_hook = hexchat.hook_print('Invited', invited_callback)
	
	def denied_callback(word, word_eol, user_data):
		if word[1] == 'Permission denied.':
			hexchat.unhook(invited_hook)
			hexchat.unhook(denied_hook)
		
		return hexchat.EAT_NONE
	
	denied_hook = hexchat.hook_print('Notice', denied_callback)
	
	hexchat.command('msg ChanServ invite {0}'.format(channel))
	
	return hexchat.EAT_HEXCHAT
示例#2
0
def on_init_cb():
    global kbd_status
    kbd_status = True
    hexchat.hook_print("Channel Msg Hilight", dispatcher, None, hexchat.PRI_LOWEST)
    hexchat.hook_print("Focus Window", notification_checked, None, hexchat.PRI_LOWEST)
    hexchat.hook_unload(unload_cb)
    hexchat.hook_command("kbdlight", toggle_kbd)
    print("\0034 {} {} {}".format(__module_name__, __module_version__,"has been loaded\003"))
示例#3
0
def on_init_cb():
    global fda_status
    fda_status = True
    hexchat.hook_print("Channel Message", freedom_alert_cb, None,
                       hexchat.PRI_LOWEST)
    hexchat.hook_unload(unload_cb)
    hexchat.hook_command("fda", toggle_fda)
    print("\0034 {} {} {}".format(__module_name__, __module_version__,
                                  "has been loaded\003"))
示例#4
0
def init():
    hexchat.hook_command(
        'pings',
        pings,
        help=
        'Usage: PINGS [date (MM-DD)] [time (hh:mm[:ss])], lists pings since time specified'
    )
    hexchat.hook_print('Channel Msg Hilight', catch_msg)
    hexchat.hook_print('Channel Action Hilight', catch_emote)
    hexchat.hook_unload(unload)
    hexchat.prnt('Loaded {} {}'.format(__module_name__, __module_version__))
示例#5
0
def init():
    try:
        if os.path.isfile(PASSFILE):
            hexchat.prnt(textPos(PASSFILE + " loaded!"))
            hexchat.hook_command('', send)
            hexchat.hook_command('enc',
                                 enc,
                                 help="For help use the command /enc")
            hexchat.hook_print('Private Message to Dialog', receive)
        else:
            hexchat.prnt(textNeg("Could not open passfile"))
    except Exception as e:
        hexchat.prnt(textNeg(str(e)))
def toggle_autopaste(*args):
    global autopaste_handler
    words = args[0]
    bools = {True: ("1", "on", "true", "t"), False: ("0", "off", "false", "f")}
    try:
        requested = words[1]
    except IndexError: # oh god
        requested = ""

# TODO
# /fc_autopaste off
# 074 [21:02:11] [Floodcontrol]  disabling autopaste
# /fc_autopaste off
# 074 [21:02:15]  Traceback (most recent call last):
# 074 [21:02:15]    File "/home/user/.config/hexchat/addons_wip/floodcontrol/floodcontrol.py", line 801, in toggle_autopaste
# 074 [21:02:15]      if requested.lower() in v:
# 074 [21:02:15]  SystemError: ../Objects/longobject.c:426: bad argument to internal function
    print_debug("toggle_autopaste requested", requested)
    if not autopaste_handler and requested.lower() not in bools[False]:
        print_fc("enabling autopaste")
        set_option("autopaste", "on")
        autopaste_handler = hexchat.hook_print("Key Press", keypress_cb)
    elif requested.lower() not in bools[True]:
        print_fc("disabling autopaste")
        set_option("autopaste", "off")
        hexchat.unhook(autopaste_handler)
        autopaste_handler = None
def greeter(word, word_eol, userdata):
    nick = word[0]
    chan = word[1]
    
    reply_hook = None
    send_hook = None
    
    def on_reply(word, word_eol, userdata):
        match = re.search('(\d\d):\d\d:\d\d', word_eol[3])
        if match:
            msg = 'Good {}'.format(daytime(match.group(1)))
        else:
            msg = 'Hello'
        
        hexchat.command('msg {} {}!'.format(chan, msg))
        
        hexchat.unhook(reply_hook)
        return hexchat.EAT_ALL
    
    def on_send(word, word_eol, userdata):
        hexchat.unhook(send_hook)
        return hexchat.EAT_ALL
    
    reply_hook = hexchat.hook_server('NOTICE', on_reply, priority=hexchat.PRI_HIGHEST)
    send_hook = hexchat.hook_print('CTCP Send', on_send, priority=hexchat.PRI_HIGHEST)
    
    hexchat.command('ctcp {} TIME'.format(nick))
    return hexchat.EAT_NONE
示例#8
0
 def decorator(func):
     wrapper = ChannelCommand(func, on_error)
     wrapper.set_command(cmd)
     wrapper.set_command_prefix(prefix)
     hookid = hexchat.hook_print('Channel Message', wrapper, userdata, priority)
     wrapper.set_hook(hookid)
     return wrapper
示例#9
0
文件: hooks.py 项目: nitori/tools
 def decorator(func):
     wrapper = ChannelCommand(func, on_error)
     wrapper.set_command(cmd)
     wrapper.set_command_prefix(prefix)
     hookid = hexchat.hook_print('Channel Message', wrapper, userdata,
                                 priority)
     wrapper.set_hook(hookid)
     return wrapper
示例#10
0
def main():
    ###########################################################################
    # Manage Preferences
    global prefs

    prefs = JSONPluginPref(__module_name__)

    if prefs.version is NotImplemented:
        print("There was an error retrieving the preferences' version.\n"
              "It is advised to seek help from the author (FichteFoll) "
              "and run around in circles.")
        return

    if prefs.version is None:  # before 0.3.0
        # convert preferences to JSON storage
        bare_prefs = PluginPref(__module_name__, prefix_sep="_")
        for key, value in bare_prefs.items():
            if key in ('announce', 'mute'):
                value = list(filter(None, value.split(",")))
            prefs[key] = value
            del bare_prefs[key]

        prefs.version = (0, 3, 0)  # hardcode for further migrations
        print("Converted preference storage to 0.3.0")

    # if prefs.version < (0, 3, 4):
    #     pass

    # Write current version at last
    prefs.version = versioninfo

    ###########################################################################
    # Register Hooks

    hexchat.hook_command("YTT", yttcmd_cb, help=HELP_STR)

    private_msg_events = ("Notice", "Private Message", "Private Action")
    for event in private_msg_events:
        hexchat.hook_print(event, privmsg_cb)

    public_msg_events = ("Channel Message", "Action", "Your Message", "Your Action")
    for event in public_msg_events:
        hexchat.hook_print(event, msg_cb)

    print(__module_name__, __module_version__, "loaded")
示例#11
0
def main():
    for evt in ('Join', 'Part'):  # 'Part with Reason' likely not necessary
        hexchat.hook_print(evt, joinpart_cb, evt, priority=hexchat.PRI_HIGH)

    # Hook modes
    hexchat.hook_print('Raw Modes', raw_modes_cb, priority=hexchat.PRI_HIGH)
    for evt in ('Channel Operator', 'Channel DeOp'):
        hexchat.hook_print(evt, eat_all_cb, evt, priority=hexchat.PRI_HIGH)

    hexchat.hook_print('Capability List', caps_cb)

    print(__module_name__, __module_version__, "loaded")
示例#12
0
def DoHook():
    global nibl_hook
    if not os.path.exists(nibl_dir + "xdccfilter"):
        file = open(nibl_dir + "xdccfilter", 'w')
        file.close()
    if nibl_hook is None:
        nibl_hook = hexchat.hook_print("Channel Message", Redirect)
        hexchat.command("MENU -t1 ADD \"NIBL/XDCC Filter\" \"nxf on\" \"nxf off\"")
    print "NIBL XDCC Filter activated"
    return hexchat.EAT_ALL
示例#13
0
def DoHook():
    global nibl_hook
    if not os.path.exists(nibl_dir + "xdccfilter"):
        file = open(nibl_dir + "xdccfilter", 'w')
        file.close()
    if nibl_hook is None:
        nibl_hook = hexchat.hook_print("Channel Message", Redirect)
        hexchat.command(
            "MENU -t1 ADD \"NIBL/XDCC Filter\" \"nxf on\" \"nxf off\"")
    print "NIBL XDCC Filter activated"
    return hexchat.EAT_ALL
示例#14
0
def toggle_debug(*args):
    global debug_handler
    global DEBUG

    if not debug_handler:
        print_fc("enabling debug")
        DEBUG = True
        debug_handler = hexchat.hook_print("Key Press", debug_keypress_cb)
    else:
        print_fc("disabling debug")
        DEBUG = False
        hexchat.unhook(debug_handler)
        debug_handler = None
示例#15
0
def toggle_debug(*args):
    global debug_handler
    global DEBUG

    if not debug_handler:
        print_fc("enabling debug")
        DEBUG = True
        debug_handler = hexchat.hook_print("Key Press", debug_keypress_cb)
    else:
        print_fc("disabling debug")
        DEBUG = False
        hexchat.unhook(debug_handler)
        debug_handler = None
示例#16
0
def toggle_autopaste(*args):
    global autopaste_handler
    words = args[0]
    bools = {True: ("1", "on", "true", "t"), False: ("0", "off", "false", "f")}
    try:
        requested = words[1].lower()
    except IndexError:
        requested = ""

    print_debug("toggle_autopaste requested", requested)
    if not autopaste_handler and requested not in bools[False]:
        print_fc("enabling autopaste")
        set_option("autopaste", "on")
        autopaste_handler = hexchat.hook_print("Key Press", keypress_cb)
    elif autopaste_handler and requested not in bools[True]:
        print_fc("disabling autopaste")
        set_option("autopaste", "off")
        hexchat.unhook(autopaste_handler)
        autopaste_handler = None
示例#17
0
def toggle_autopaste(*args):
    global autopaste_handler
    words = args[0]
    bools = {True: ("1", "on", "true", "t"), False: ("0", "off", "false", "f")}
    try:
        requested = words[1].lower()
    except IndexError:
        requested = ""

    print_debug("toggle_autopaste requested", requested)
    if not autopaste_handler and requested not in bools[False]:
        print_fc("enabling autopaste")
        set_option("autopaste", "on")
        autopaste_handler = hexchat.hook_print("Key Press", keypress_cb)
    elif autopaste_handler and requested not in bools[True]:
        print_fc("disabling autopaste")
        set_option("autopaste", "off")
        hexchat.unhook(autopaste_handler)
        autopaste_handler = None
示例#18
0
def do_hook(redir):
    def _hook(*args, **kwargs):
        if hexchat.get_info("channel") == redir.target:
            return hexchat.EAT_NONE  # nothing to do
        if redir.network and redir.network != hexchat.get_info("network"):
            return hexchat.EAT_NONE
        if redir.channel and redir.channel != hexchat.get_info("channel"):
            return hexchat.EAT_NONE
        if re.search(redir.regex, '|'.join(args[0])):  # args[1] is word_eol
            if redir.target:
                ctx = hexchat.find_context(channel=redir.target)
                if ctx == None:
                    hexchat.command("query " + redir.target)
                    ctx = hexchat.find_context(channel=redir.target)
                ctx.emit_print(redir.command, *args[0])
            return hexchat.EAT_ALL
        return hexchat.EAT_NONE
    print("Hooking \x0303{command}\x0f with regex \x0303{regex}\x0f (\x0304{network}\x0f/\x0304{channel}\x0f) => \x0305{target}\x0f".format(**redir.serialize()))
    redir.handler = hexchat.hook_print(redir.command, _hook)
示例#19
0
def autogetkey_callback(word, word_eol, user_data):
	channel = word[0]
	
	def getkey_callback(word, word_eol, user_data):
		key = ''
		
		matches = re.match('KEY {0} (.*)$'.format(channel), word[1]) or re.match('Channel \x02{0}\x02 key is: (.*)$'.format(channel), word[1])
		if matches:
			hexchat.unhook(getkey_hook)
			key = matches.group(1)
		
		elif word[1] == 'Access denied.' or word[1] == 'You are not authorized to perform this operation.':
			hexchat.unhook(getkey_hook)
		
		if key:
			hexchat.command('join {0} {1}'.format(channel, key))
	
	getkey_hook = hexchat.hook_print('Notice', getkey_callback)
	
	hexchat.command('msg ChanServ getkey {0}'.format(channel))
示例#20
0
def banned_callback(word, word_eol, user_data):
	channel = word[0]
	
	def notice_callback(word, word_eol, user_data):
		unban_result = hexchat.EAT_NONE
		nickname = hexchat.get_info('nick')
		
		if re.search(r'{0} has been unbanned from {1}\.'.format(nickname, channel), hexchat.strip(word[1])):
			hexchat.unhook(notice_hook)
			unban_result = hexchat.EAT_HEXCHAT
			hexchat.command('join {0}'.format(channel))
		
		elif word[1] == 'Permission denied.':
			hexchat.unhook(notice_hook)
		
		return unban_result
	
	notice_hook = hexchat.hook_print('Notice', notice_callback)
	
	hexchat.command('msg ChanServ unban {0}'.format(channel))
	
	return hexchat.EAT_HEXCHAT
示例#21
0
    def handle(self, channel, event, words):
        if not self.enabled:
            return False
        if not self.regex.search(words[1]):
            return False

        if self.strip:
            words[1] = hexchat.strip(words[1], -1, self.strip)
        if self.replacement is not None:
            words[1] = self.regex.sub(self.replacement, words[1])
        if self.wrap_line is not None:
            words[1] = self.wrap_line[0] + words[1] + self.wrap_line[1]
            words[0] = self.wrap_line[0] + words[0] + self.wrap_line[1]

        hexchat.unhook(event_hooks[event])
        hexchat.emit_print(event, *words)
        event_hooks[event] = hexchat.hook_print(event, message_hook, event)

        if self.abs_sound is not None and not self.mute:
            playsound(self.abs_sound)

        return True
示例#22
0
def autogetkey_callback(word, word_eol, user_data):
    channel = word[0]

    def getkey_callback(word, word_eol, user_data):
        key = ''

        matches = re.match(
            'KEY {0} (.*)$'.format(channel), word[1]) or re.match(
                'Channel \x02{0}\x02 key is: (.*)$'.format(channel), word[1])
        if matches:
            hexchat.unhook(getkey_hook)
            key = matches.group(1)

        elif word[1] == 'Access denied.' or word[
                1] == 'You are not authorized to perform this operation.':
            hexchat.unhook(getkey_hook)

        if key:
            hexchat.command('join {0} {1}'.format(channel, key))

    getkey_hook = hexchat.hook_print('Notice', getkey_callback)

    hexchat.command('msg ChanServ getkey {0}'.format(channel))
示例#23
0
def show_hints(word, word_eol, userdata):
    global halt, hint_hook, hooked
    if not word == ['88', '21', '\x18', '1']:
        return
    if hooked is True:
        hexchat.unhook(hint_hook)
        hooked = False
    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
示例#24
0
def banned_callback(word, word_eol, user_data):
    channel = word[0]

    def notice_callback(word, word_eol, user_data):
        unban_result = hexchat.EAT_NONE
        nickname = hexchat.get_info('nick')

        if re.search(
                r'{0} has been unbanned from {1}\.'.format(nickname, channel),
                hexchat.strip(word[1])):
            hexchat.unhook(notice_hook)
            unban_result = hexchat.EAT_HEXCHAT
            hexchat.command('join {0}'.format(channel))

        elif word[1] == 'Permission denied.':
            hexchat.unhook(notice_hook)

        return unban_result

    notice_hook = hexchat.hook_print('Notice', notice_callback)

    hexchat.command('msg ChanServ unban {0}'.format(channel))

    return hexchat.EAT_HEXCHAT
示例#25
0
        hexchat.prnt("-\002Follow\002-\tYou have unfollowed \002\003{0}{1}\017".format(nick_color(word[1]), word[1]))
        return hexchat.EAT_ALL


def format_cb(word, word_eol, event):
    global edited
    nick = hexchat.strip(word[0])

    if edited:
        return

    if nick in userlist:
        formatted_nick = "\002{0}\017".format(word[0])
        # TODO: Use regular nick color for formatted_msg if colored nickname preference is disabled
        formatted_msg = "\003{0}{1}\017".format(nick_color(nick), word[1])
        word = [(word[i] if len(word) > i else "") for i in range(4)]

        edited = True
        hexchat.emit_print(event, formatted_nick, formatted_msg, word[2], word[3])
        edited = False

        return hexchat.EAT_ALL


hexchat.hook_command("FOLLOW", follow_cb)
hexchat.hook_command("UNFOLLOW", unfollow_cb)
hexchat.hook_print("Channel Action", format_cb, "Channel Action", priority=hexchat.PRI_HIGH)
hexchat.hook_print("Channel Message", format_cb, "Channel Message", priority=hexchat.PRI_HIGH)

hexchat.prnt(__module_name__ + " version " + __module_version__ + " loaded")
示例#26
0
__module_name__ = 'Typing'
__module_author__ = 'OverCoder'
__module_version__ = '1.0'
__module_description__ = 'Send /me is typing... when typing'

enabled = False
typing = False

def toggle(words, word_eols, userdata):
    global enabled
    enabled = not enabled
    if enabled:
    	hexchat.prnt("\"Typing...\" is now enabled")
    else:
    	hexchat.prnt("\"Typing...\" is now disabled")

def paste(key, data, userdata):
    global typing
    global enabled
    if not enabled:
        return hexchat.EAT_NONE
    if key[0] == "65293":
        typing = False
    elif not typing:
        typing = True
        hexchat.command("me is typing...")
    return hexchat.EAT_NONE

hexchat.hook_print("Key Press", paste)
hexchat.hook_command("typing", toggle)
示例#27
0
	print(f"\002**\002 IP '\002{ip_address}\002' resolves to decimal IP '\002{decip}\002'")
	return hexchat.EAT_HEXCHAT	

hexchat.hook_command('ip2dec', command_ip2dec, help=help['ip2dec'])



#### Hooks & Callbacks ####


def hook_invite(channel, channel_eol, params):
	hexchat.command(f"JOIN {channel[0]}")
	return hexchat.EAT_NONE

if join_on_invite == True:
	hexchat.hook_print( "Invited", hook_invite)


def hook_opendialogue(window, window_eol, params):
	hexchat.command(f"whois {hexchat.get_info('channel')}");
	return hexchat.EAT_NONE;

if whois_on_private == True:
	hexchat.hook_print( "Open Dialog", hook_opendialogue)


def hook_ctcp(ctcp, ctcp_eol, params):
	if ctcp[0].upper() == "OS":
		try:
			system = platform.linux_distribution()
			hexchat.command(f"nctcp {ctcp[1]} OS Operating System: {system[0]} {system[1]}") 
示例#28
0
    global limit
    limit = 0
    return 0


def unban(word, word_eol, userdata):
    global limit
    if limit == 0:
        nick = hexchat.get_info('nick')
        hexchat.command('RAW PRIVMSG ChanServ :UNBAN %s %s' % (userdata, nick))
        hexchat.command('timer 1 RAW JOIN %s' % userdata)
        limit = 1
        hexchat.hook_timer(2000, timereset)
    return hexchat.EAT_PLUGIN


hexchat.hook_print('You Kicked', rejoin)


def nwo_unloaded(userdata):
    hexchat.emit_print(
        'Notice', '', '%s v%s by %s unloaded' %
        (__module_name__, __module_version__, __module_author__))
    return hexchat.EAT_ALL


hexchat.emit_print(
    'Notice', '', '%s v%s by %s loaded' %
    (__module_name__, __module_version__, __module_author__))
hexchat.hook_unload(nwo_unloaded)
示例#29
0
        # For each bot in the existing bots
        for channel_bots in botnames:
            # check if the existing bot list has entry for the current channel
            if channel_bots == current_channel:
                # .. and if the nick of the sender matches the botname
                if nick == botnames[channel_bots]:
                    # Iterate through all the probable bots for the channel
                    for duck in all_ducks[current_channel]:
                        # If the bot in the list exists in the message
                        if duck in message:
                            # Let us process the duck
                            process_duck(duck, current_channel)
    # Silently ignore any errors we come across, not really good practice, but meh.
    except Exception:
        pass
    # Let hexchat know that it shouldn't do anything with the existing text event
    return hexchat.EAT_NONE


# This is the method that first gets called when the it detects a channel message
# It creates a new thread for every message, so it doesn't freeze hexchat.
def thread(word, word_eol, userdata):
    threading.Thread(
        target=check_duck,
        args=(word, word_eol, userdata)
    ).start()

print "\002%s has loaded it's machine gun. Ready to shoot me some duck." % __module_name__
# Hook on to the "Channel Message" text event
hexchat.hook_print("Channel Message", thread)
示例#30
0
    def start_blinking(self, word, word_eol, userdata):
        self.blink = True
        do_thread = Thread(target=self.handle_start_blinking)
        do_thread.start()

    def stop_blinking(self, word, word_eol, userdata):
        self.blink = False
        do_thread = Thread(target=self.handle_stop_blinking)
        do_thread.start()


alert = RazerAlert()

hexchat.hook_command(
    "soundalert",
    alert.set_options,
    help=
    "/soundalert set <directory> -- Sets a directory for Sound Alert to pull sounds from."
)
hexchat.hook_command("alertson",
                     alert.enable,
                     help="Turns on soundalert alerts.")
hexchat.hook_command("alertsoff",
                     alert.disable,
                     help="Turns off soundalert alerts.")
hexchat.hook_print("Channel Action Hilight", alert.start_blinking)
hexchat.hook_print("Channel Msg Hilight", alert.start_blinking)
hexchat.hook_print("Private Message", alert.start_blinking)
hexchat.hook_print("Focus Window", alert.stop_blinking)
示例#31
0

# load_data()

# champion static data
# response = requests.get('https://global.api.pvp.net/api/lol/static-data/na/v1.2/champion?api_key={api_key}'.format(api_key=fetch_riot_key()))
# champion_data = response.json()
# logging.debug(champion_data['data'])
# for champ in champion_data['data']:
#     CHAMPIONS[champion_data['data'][champ]['id']] = champion_data['data'][champ]['name']
#     logging.debug(str(champion_data['data'][champ]['id'])+':\''+champion_data['data'][champ]['name']+'\',')

# runes static data
# response = requests.get('https://global.api.pvp.net/api/lol/static-data/na/v1.2/rune?api_key={api_key}'.format(api_key=fetch_riot_key()))
# runes_data = response.json()
# for rune in runes_data['data']:
#     RUNES[runes_data['data'][rune]['id']] = runes_data['data'][rune]['name']
# logging.debug(RUNES)

hook_4 = hexchat.hook_timer(300 * 1000, refresh_channels)
hexchat.hook_print('Channel Message',
                   channel_message_cb)  # respond to Twitch chat messages

# local only versions
# update_cb('')
# hexchat.hook_timer(3000, update_cb)
# hexchat.hook_print('Channel Message', channelmessage_cb)

# hexchat.hook_timer(5000, loaded_cb)
hexchat.hook_unload(unload_cb)
示例#32
0
    global whois
    whois.append(word[0] + " has been idle for " + word[1])
    return hexchat.EAT_ALL

def whois_signon(word, word_eol, userdata):
    global whois
    whois.append(word[0] + " has been idle for " + word[1])
    whois.append(word[0] + " signed in on " + word[2])
    return hexchat.EAT_ALL

def whois_auth(word, word_eol, userdata):
    global whois
    whois.append(word[0] + " is logged in as " + word[2])
    return hexchat.EAT_ALL

#Hooks

hexchat.hook_print("WhoIs Name Line", whois_name)
hexchat.hook_print("WhoIs Channel/Oper Line", whois_chan)
hexchat.hook_print("WhoIs Server Line", whois_serv)
hexchat.hook_print("WhoIs Identified", whois_ident)
hexchat.hook_print("WhoIs Away Line", whois_away)
hexchat.hook_print("WhoIs Special", whois_special)
hexchat.hook_print("WhoIs Idle Line", whois_idle_line)
hexchat.hook_print("WhoIs Idle Line with Signon", whois_signon)
hexchat.hook_print("WhoIs Authenticated", whois_auth)
hexchat.hook_print("WhoIs End", whois_end)

#Load message

print __module_name__, __module_version__,"has been loaded."
示例#33
0
	return



def unload(userdata):
	hexchat.unhook(command_hook)
	hexchat.unhook(DCC_complete_hook)
	hexchat.unhook(unload_hook)
	print("\00310\002ユイ\017 v%s plugin by \00311\002Wizongod\017 has been unloaded." % __module_version__)
	return



# Hooks for detecting events
command_hook = hexchat.hook_command('xdcc', commander)
DCC_complete_hook = hexchat.hook_print('DCC RECV Complete',XDCC_complete)
unload_hook = hexchat.hook_unload(unload)



def is_valid_pack(pack_no):
	if strip_hash(pack_no).isdigit():
		return True
	else:
		return False



def strip_hash(string):
	if string[0] == "#":
		return string[1:]
示例#34
0
import hexchat

__module_name__ = 'RequireSASL'
__module_author__ = 'TingPing'
__module_version__ = '1'
__module_description__ = 'Disconnect if SASL fails'

def response_cb(word, word_eol, userdata):
	if word[1] == '904': # Failed
		hexchat.command('timer .1 discon') # Delay so disconnect happens after message.

hexchat.hook_print('SASL Response', response_cb)
示例#35
0
        hexchat.unhook(hook_2)
        hexchat.unhook(hook_3)
    if mode == 'on':
        hook_1 = hexchat.hook_timer(
            5 * 1000,
            refresh_live_streams)  # update which streams are currently live
        hook_2 = hexchat.hook_timer(
            5 * 1000, update_twitch_title)  # update twitch titles
        hook_3 = hexchat.hook_timer(
            5 * 1000,
            update_database_cb)  # update the database with new Riot API info


def unload_cb(userdata):
    conn.commit()
    c.close()
    conn.close()
    print('==========Hoffmannbot Updater unloaded==========')


print('==========Hoffmannbot Updater loaded==========')

hook_1 = None
hook_2 = None
hook_3 = None
# hook_1 = hexchat.hook_timer(5 * 1000, refresh_live_streams)  # update which streams are currently live
# hook_2 = hexchat.hook_timer(5 * 1000, update_twitch_title)  # update twitch titles
# hook_3 = hexchat.hook_timer(5 * 1000, update_database_cb)  # update the database with new Riot API info
hook_4 = hexchat.hook_print('Channel Message', channel_message_cb)
hexchat.hook_unload(unload_cb)
示例#36
0
        hexchat.prnt('AESKEY: no key set; use while in a channel')
        return hexchat.EAT_ALL
    channel_keys[server + channel] = word[1]
    # base64 encode so passwords don't show up with grep or something similar
    hexchat.set_pluginpref(
        __module_name__, base64.standard_b64encode(repr(channel_keys))
    )
    hexchat.prnt('AESKEY: key for {} @ {} set'.format(channel, server))
    return hexchat.EAT_ALL


if __module_name__ in hexchat.list_pluginpref():
    import ast
    keys_b64 = hexchat.get_pluginpref(__module_name__)
    try:
        keys_string = base64.standard_b64decode(keys_b64)
        channel_keys = ast.literal_eval(keys_string)
    except TypeError as ex:
        pass


hexchat.hook_print('Channel Message', decrypt_privmsg)
hexchat.hook_command('', encrypt_privmsg)  # sending regular message
hexchat.hook_command('ACTION', encrypt_privmsg, 'CTCP')
hexchat.hook_command('ME', encrypt_privmsg, 'CTCP')
hexchat.hook_command('AESKEY', set_aes_key,
                     help='/AESKEY "<key>"  Set an encryption key for '
                          'the current channel. Blank key to unset.')
hexchat.hook_unload(lambda x: hexchat.prnt(__module_name__ + ' unloaded'))
hexchat.prnt(__module_name__ + ' loaded')
示例#37
0
__module_name__ = 'AutoUnban'
__module_version__ = '1.0'
__module_description__ = ''

hexchat.prnt('AutoUnban script loaded')

def banned_callback(word, word_eol, user_data):
	channel = word[0]
	
	def notice_callback(word, word_eol, user_data):
		unban_result = hexchat.EAT_NONE
		nickname = hexchat.get_info('nick')
		
		if re.search(r'{0} has been unbanned from {1}\.'.format(nickname, channel), hexchat.strip(word[1])):
			hexchat.unhook(notice_hook)
			unban_result = hexchat.EAT_HEXCHAT
			hexchat.command('join {0}'.format(channel))
		
		elif word[1] == 'Permission denied.':
			hexchat.unhook(notice_hook)
		
		return unban_result
	
	notice_hook = hexchat.hook_print('Notice', notice_callback)
	
	hexchat.command('msg ChanServ unban {0}'.format(channel))
	
	return hexchat.EAT_HEXCHAT

hexchat.hook_print('Banned', banned_callback, priority=hexchat.PRI_HIGHEST)
示例#38
0
import re

__module_name__ = 'AutoGetkey'
__module_version__ = '1.0'
__module_description__ = ''

hexchat.prnt('AutoGetkey script loaded')

def autogetkey_callback(word, word_eol, user_data):
	channel = word[0]
	
	def getkey_callback(word, word_eol, user_data):
		key = ''
		
		matches = re.match('KEY {0} (.*)$'.format(channel), word[1]) or re.match('Channel \x02{0}\x02 key is: (.*)$'.format(channel), word[1])
		if matches:
			hexchat.unhook(getkey_hook)
			key = matches.group(1)
		
		elif word[1] == 'Access denied.' or word[1] == 'You are not authorized to perform this operation.':
			hexchat.unhook(getkey_hook)
		
		if key:
			hexchat.command('join {0} {1}'.format(channel, key))
	
	getkey_hook = hexchat.hook_print('Notice', getkey_callback)
	
	hexchat.command('msg ChanServ getkey {0}'.format(channel))

hexchat.hook_print('Keyword', autogetkey_callback)
示例#39
0
 def __init__(self):
     hexchat.prnt('loaded')
     hexchat.hook_print('Channel Message', self.main)
     self.state = 'main_menu'
示例#40
0
    if hexchat.get_info('network') == config["network"] and hexchat.get_info(
            "channel") == config["channel"]:
        if word[0].lower() in config["override"]:
            pass
        else:
            if word[0][::-1].lower() == ident.lower():
                word[0] = word[0][::-1]
            else:
                if hasNumbers(word[0]):
                    word[0] = ''.join([i for i in word[0] if not i.isdigit()])
                    hexchat.command("sanick %s %s" % (word[0], word[0][::-1]))
                else:
                    hexchat.command("sanick %s %s" % (word[0], word[0][::-1]))


hexchat.hook_print("Join", userJoin)


def revnick(word, word_eol, userdata):
    try:
        word[1]
        print(word[1])
    except IndexError:
        print("Please enter a nick.")
    else:
        word.pop(0)
        for name in word:
            newNick = newNick = word[1][::-1]
            hexchat.command("sanick %s %s" % (name, newNick.title()))

示例#41
0
def register(words, word_eols, userdata):
    if len(words) < 2:
        hexchat.prnt("You did not specify a channel")
    elif words[1] in channels:
        hexchat.prnt("Removed \002{}\002 from caps list".format(words[1]))
        channels.remove(words[1])
    else:
        hexchat.prnt("Capitalization is now enabled for \002{}\002".format(
            words[1]))
        channels.append(words[1])
    return hexchat.EAT_ALL


def send(key, data, userdata):
    if key[0] == "65293":
        user_input = hexchat.get_info("inputbox")
        if hexchat.get_info("channel") in channels:
            if user_input.startswith("/") and not user_input.startswith("/me"):
                return hexchat.EAT_NONE
            hexchat.command("say {}".format(user_input.upper()))
            hexchat.command("settext  ")
            return hexchat.EAT_ALL
    return hexchat.EAT_NONE


hexchat.hook_command(
    "caps",
    register,
    help="/caps <channel> : Capitalize all text sent to the specified channel")
hexchat.hook_print("Key Press", send)
示例#42
0
def generate_colour(last_colour):
    colour_code = ""
    
    while True:
        colour_code = "\00300," + str(random.randint(1, 12))
        
        if not colour_code == last_colour:
            break
        
    return colour_code

def rainbow(key, data, userdata):
    global enabled
    if not enabled:
        return hexchat.EAT_NONE
    if key[0] == "65293":
        if (hexchat.get_info("inputbox").startswith("/")):
            return hexchat.EAT_NONE
        output = "\002"
        colour = ""
        for word in hexchat.get_info("inputbox").strip(" ").split(" "):
            colour = generate_colour(colour)
            output = output + colour + " " + word + " "
        hexchat.command("say " + output)
        hexchat.command("settext  ")
        return hexchat.EAT_ALL
    return hexchat.EAT_NONE

hexchat.hook_print("Key Press", rainbow)
hexchat.hook_command("rainbow", toggle)
示例#43
0
import hexchat
import requests
import json

__module_name__ = 'qbin'
__module_author__ = 'OverCoder'
__module_version__ = '1.1'
__module_description__ = 'Pastes to qbin and sends link'
command = "/qbin"


def paste(key, data, userdata):
    if key[0] == "65293":
        if hexchat.get_info("inputbox").startswith(command):
            try:
                req = requests.post(
                    "https://qbin.io/",
                    {"Q": hexchat.get_info("inputbox")[len(command) + 1:]})
                hexchat.command("say " + req.text.strip())
                hexchat.command("settext  ")
            except:
                hexchat.command("settext  ")
            return hexchat.EAT_ALL
    return hexchat.EAT_NONE


hexchat.hook_print("Key Press", paste)
示例#44
0
__module_version__ = '1.0'
__module_description__ = ''

hexchat.prnt('Highlight Logger loaded')

tab_name = '(Highlights)'


def highlight_callback(word, word_eol, user_data):
    word = [(word[i] if len(word) > i else '') for i in range(4)]

    channel = hexchat.get_info('channel')
    highlight_context = hexchat.find_context(channel=tab_name)

    if user_data == 'Channel Msg Hilight':
        highlight_context.prnt('{0}\t\00320<{4}{3}{1}> {2}'.format(
            channel, word[0], word[1], word[2], word[3]))
    elif user_data == 'Channel Action Hilight':
        highlight_context.prnt('{0}\t\00320{4}{3}{1} {2}'.format(
            channel, word[0], word[1], word[2], word[3]))

    return hexchat.EAT_NONE


hexchat.hook_print('Channel Msg Hilight', highlight_callback,
                   'Channel Msg Hilight')
hexchat.hook_print('Channel Action Hilight', highlight_callback,
                   'Channel Action Hilight')

hexchat.command('query {0}'.format(tab_name))
示例#45
0
def lurk_pastebin(word, word_eol, event):
    user = word[0].strip()
    mess = word[1].strip()
    service = filter(lambda x: x[0] in mess, PASTEBIN_SERVICES)
    if len(service) == 0 or len(service) > 1:
        return

    service = service[0]
    pasteid = mess[mess.find(service[0]):].replace(service[0], "")
    rawurl = service[1] + pasteid
    r = requests.get(rawurl)
    if r.status_code != 200:
        s("Request failed for %s with %d" % (rawurl, r.status_code))
        return

    s("%s:" % (rawurl))
    c(pasteid, r.text)
    return

def new_msg(word, word_eol, event):
    t = Thread(target=lurk_pastebin, args=(word, word_eol, event, ))
    t.start()
    return None

hooks_new = ["Your Message", "Channel Message"]
for hook in hooks_new:
    hexchat.hook_print(hook, new_msg, hook, hexchat.PRI_LOWEST)

p("successfully loaded.")
示例#46
0
			return hexchat.EAT_ALL
		elif word[3] in (':USERCOLOR', ':USERSTATE', ':HISTORYEND', ':EMOTESET', ':CLEARCHAT', ':SPECIALUSER'):
			return hexchat.EAT_ALL

# Eat any message starting with a '.', twitch eats all of them too.
@twitchOnly
def yourmsg_cb(word, word_eol, userdata):
	if word[1][0] == '.':
		return hexchat.EAT_ALL

# Just prefix with a '.'.
@twitchOnly
def command_cb(word, word_eol, alias):
	if alias:
		if len(word_eol) > 1:
			hexchat.command('say .{} {}'.format(alias, word_eol[1]))
		else:
			hexchat.command('say .{}'.format(alias))
	else:
		hexchat.command('say .{}'.format(word_eol[0]))
	return hexchat.EAT_ALL

for command in commands:
	hexchat.hook_command(command, command_cb)
for command, alias in aliases.items():
	hexchat.hook_command(command, command_cb, alias)
hexchat.hook_print('Your Message', yourmsg_cb)
hexchat.hook_server('421', servererr_cb)
#hexchat.hook_server('376', endofmotd_cb)
hexchat.hook_server('PRIVMSG', privmsg_cb)
last_highlights = {}

def highlight_callback(word, word_eol, user_data):
	word = [(word[i] if len(word) > i else '') for i in range(4)]
	
	result = hexchat.EAT_NONE
	
	now = datetime.datetime.now()
	dictionary_key = '{0}{1}'.format(hexchat.get_info('network'), hexchat.get_info('channel'))
	
	last_highlight = last_highlights.get(dictionary_key)
	
	if last_highlight is not None and last_highlight.nickname == word[0] and (now - last_highlight.time).total_seconds() <= 5 * 60:
		hexchat.emit_print(user_data, word[0], word[1], word[2], word[3])
		result = hexchat.EAT_ALL
	
	last_highlights[dictionary_key] = LastHighlightRecord(word[0], now)
	
	return result

def reset_last_highlight_callback(word, word_eol, user_data):
	dictionary_key = '{0}{1}'.format(hexchat.get_info('network'), hexchat.get_info('channel'))
	
	last_highlights[dictionary_key] = None

hexchat.hook_print('Channel Msg Hilight', highlight_callback, 'Channel Message', priority=hexchat.PRI_HIGHEST)
hexchat.hook_print('Channel Action Hilight', highlight_callback, 'Channel Action', priority=hexchat.PRI_HIGHEST)

hexchat.hook_print('Channel Message', reset_last_highlight_callback)
hexchat.hook_print('Channel Action', reset_last_highlight_callback)
KEY_MOD_CTRL = 1 << 2
KEY_MOD_ALT = 1 << 3


def on_key_press(word, word_eol, userdata):
    msg = hexchat.get_info('inputbox')
    pos = hexchat.get_prefs('state_cursor')
    # If this fails for you, it's because of
    # https://github.com/hexchat/hexchat/issues/869
    key = int(word[0])
    modifier = int(word[1])

    if not msg:
        return

    if (
        pos
        and key in (KEY_TAB, KEY_SPACE)
        and not (modifier & KEY_MOD_SHIFT)
        and msg[pos - 1] == "#"
    ):
        channel = hexchat.get_info('channel')
        msg = msg[:pos - 1] + channel + msg[pos:]
        hexchat.command("settext %s" % msg)
        hexchat.command("setcursor %d" % (pos + len(channel) - 1))

if __name__ == '__main__':
    hexchat.hook_print('Key Press', on_key_press)

    print("%s %s loaded" % (__module_name__, __module_version__))
示例#49
0
    hexchat.command('say %s' % url.strip())


def auto_paste(word, word_eol, userdata):
    if not word or len(word) < 3:
        return None
    if word[2] != '\r':
        return None
    inputbox = hexchat.get_info('inputbox')
    if not inputbox:
        return None
    if inputbox[0] == '/' and inputbox[1] != '/':
        return None  # don't take any chances. don't touch commands.

    if '\n' not in inputbox:
        return None
    c = inputbox.count('\n')
    if c < 4:
        return None

    hexchat.prnt('More than 4 lines. Uploading as a paste.')
    hexchat.command('settext')
    Thread(target=worker, args=(inputbox,)).start()
    return hexchat.EAT_HEXCHAT

# We need to use a key press hook because the other events clear
# the input box first, and split the message up.. so lots of events
# fire and no way to tell if they're grouped.
hexchat.hook_print('Key Press', auto_paste)
示例#50
0
            return hexchat.EAT_ALL

def addignore(word, word_eol, userdata):
    global ignorelist
    ignorelist.append(word[1])
    savelist()
    return hexchat.EAT_ALL

def delignore(word, word_eol, userdata):
    global ignorelist
    try:
        ignorelist.remove(word[1])
        savelist()
    except: pass
    return hexchat.EAT_ALL

def printlist():
    global ignorelist
    if len(ignorelist) == 0:
        hexchat.prnt('Ignorelist is empty')
        return
    hexchat.prnt('Ignorelist: ' + ' '.join(ignorelist))

loadlist()
hexchat.hook_print("Channel Message", ignore, "Channel Message")
hexchat.hook_print("Channel Msg Hilight", ignore, "Channel Msg Hilight")
hexchat.hook_command("addignore", addignore)
hexchat.hook_command("delignore", delignore)
hexchat.prnt(__module_name__ + " " + __module_version__ + " loaded!")
printlist()
示例#51
0
        else:
            hexchat.command('say /{}'.format(alias))
    else:
        hexchat.command('say /{}'.format(word_eol[0]))
    return hexchat.EAT_ALL


for command in commands:
    hexchat.hook_command(command, command_cb)
for command, alias in aliases.items():
    hexchat.hook_command(command, command_cb, alias)
hexchat.hook_command('', my_saymsg_cb)
hexchat.hook_command('msg', my_msg_cb)
hexchat.hook_command('notice', my_msg_cb)
hexchat.hook_server('421', servererr_cb)
hexchat.hook_server('PRIVMSG', privmsg_cb)
hexchat.hook_server('CLEARCHAT', clearchat_cb)
hexchat.hook_server('WHISPER', whisper_cb)
hexchat.hook_server('RECONNECT', reconnect_cb)
hexchat.hook_server('HOSTTARGET', hosttarget_cb)
hexchat.hook_server('USERSTATE', eatall)
hexchat.hook_server('GLOBALUSERSTATE', eatall)
hexchat.hook_server('HISTORYEND', eatall)
hexchat.hook_server('SPECIALUSER', eatall)
hexchat.hook_server('ROOMSTATE', eatall)
hexchat.hook_print('Your Message', yourmsg_cb)
hexchat.hook_print('Your Action', youract_cb)
# Obsolete
# hexchat.hook_server('EMOTESET', eatall)
# hexchat.hook_server('USERCOLOR', eatall)
示例#52
0
import hexchat

__module_name__ = 'AutoRejoin'
__module_version__ = '1.0'
__module_description__ = ''

hexchat.prnt('Autorejoin script loaded')


def autorejoin_callback(word, word_eol, user_data):
    hexchat.hook_timer(3000, rejoin_timer_callback, word[1])


def rejoin_timer_callback(user_data):
    hexchat.command('join {0}'.format(user_data))


hexchat.hook_print('You Kicked', autorejoin_callback)
示例#53
0
            if word[1] == "set":
                if os.path.isdir(word_eol[1]):
                    hexchat.set_pluginpref("soundalert_dir", word_eol[1])

                else:
                    hexchat.prnt("Not a valid directory.")

        return hexchat.EAT_ALL

    def spawn(self, word, word_eol, userdata):
        do_thread = Thread(target=self.play_sound)
        do_thread.start()


alert = SoundAlert()

hexchat.hook_command(
    "soundalert",
    alert.set_options,
    help=
    "/soundalert set <directory> -- Sets a directory for Sound Alert to pull sounds from."
)
hexchat.hook_command("alertson",
                     alert.enable,
                     help="Turns on soundalert alerts.")
hexchat.hook_command("alertsoff",
                     alert.disable,
                     help="Turns off soundalert alerts.")
hexchat.hook_print("Channel Action Hilight", alert.spawn)
hexchat.hook_print("Channel Msg Hilight", alert.spawn)
hexchat.hook_print("Private Message", alert.spawn)
示例#54
0
                return

    net = hexchat.get_info('network')
    if not net:
        net = hexchat.get_info('server')
    if not net:
        return

    chan = hexchat.get_info('channel')
    if not chan:
        return

    close_history.append('irc://{}/{}'.format(net, chan))


def keypress_cb(word, word_eol, userdata):
    global close_history

    key, mod = word[0], get_valid_mod(word[1])

    if (key, mod) == ('84', shiftctrlmod):  # Ctrl+Shift+t
        try:
            last = close_history.pop()
            hexchat.command('url {}'.format(last))
        except IndexError:
            pass


hexchat.hook_print("Close Context", contextclosed_cb)
hexchat.hook_print('Key Press', keypress_cb)
示例#55
0
文件: acm.py 项目: fofp/cocktography
    hexchat.emit_print(cmds[cmd][b'event'],
                       sformat(hexchat.get_info(b'nick'), flags[b'strokes']),
                       args)
    return hexchat.EAT_HEXCHAT


def dechode(word, word_eol, userdata):
    dechoded = api.dechode(word_eol[1])
    for text, strokes in dechoded:
        payload = b'[dechoded {}-strokes] {}'.format(strokes, text)
        hexchat.prnt(payload)
    return hexchat.EAT_HEXCHAT


__module_name__ = b'acm'
__module_version__ = b'1.3'
__module_description__ = b'Auto-Cocktographic Messaging'

hexchat.hook_print(b'Channel Message', autococktography_cmsg)
hexchat.hook_print(b'Channel Action', autococktography_caction)
hexchat.hook_print(b'Private Message', autococktography_pmsg)
hexchat.hook_print(b'Private Action', autococktography_paction)
hexchat.hook_print(b'Private Message to Dialog', autococktography_pdmsg)
hexchat.hook_print(b'Private Action to Dialog', autococktography_pdaction)

hexchat.hook_command(b'enchode', enchode)
hexchat.hook_command(b'dechode', dechode)

hexchat.prnt(b'{} version {} loaded'.format(__module_name__,
                                            __module_version__))
示例#56
0
            print("Failed to load entry {}:".format(ix), str(ex))
            ok = False
            continue
        key = alert.name.lower()
        if key in alerts:
            print(
                "Failed to load entry {}: Alert '{}' duplicated in save data.".
                format(ix, alert.name))
            ok = False
            continue
        alerts[key] = alert


def unload_hook(userdata):
    save()


print(("{name} version {version} loaded.  Type " + IRC.bold("/alerts help") +
       " for usage instructions").format(name=__module_name__,
                                         version=__module_version__))
load()
print("{} alert(s) loaded".format(len(alerts)))
hexchat.hook_unload(unload_hook)
hexchat.hook_command("alerts", command_hook, help="Configures custom alerts")

event_hooks = {}
for event in ("Channel Msg Hilight", "Channel Message", "Channel Action",
              "Private Message", "Private Message to Dialog", "Private Action",
              "Private Action to Dialog"):
    event_hooks[event] = hexchat.hook_print(event, message_hook, event)
示例#57
0
# Usage:
# 0. copy plugin into HexChat directory: ~/.config/hexchat/addons/
# 1. fire up HexChat
# 2. store the words you want to highlight comma-separated in a variable:
# /py exec import hexchat; hexchat.set_pluginpref('highlight_extrawords', 'service:,all:,...')
# 3. reload plugin
# /reload highlight_extrawords.py
# 4. done

__module_name__ = "highlight_extrawords"
__module_version__ = "0.1"
__module_description__ = "Highlight extra words with punctuation"

import hexchat
extrawords = hexchat.get_pluginpref('highlight_extrawords')
if extrawords:
    extrawords = [ w.strip() for w in extrawords.split(',') ]
else:
    extrawords = []

def highlight(words, word_eol, userdata):
    """Highlight words in extra words
    """
    if words:
        for word in words[1].split():
            if word.strip().lower() in extrawords:
                hexchat.command('TRAY -b "%s" "%s"' % (words[0], words[1]))
                return

hexchat.hook_print('Channel Message', highlight)