Пример #1
0
def WhoScanStart(userdata):
    #print('timer started')
    global AllUsers
    global AllChannels
    for network in list(ScanProgress.keys()):
        if len(ScanProgress[network]) != 0:
            # hexchat.find_context().prnt('scan is in progress')
            return 1 # To keep the timer running
    AllChannels = {}
    allchannels = hexchat.get_list('channels')
    for channel in allchannels:
        if channel.type == 2:
            if channel.network not in list(AllChannels.keys()):
                AllChannels[channel.network] = [channel.channel]
            else:
                if channel.channel not in AllChannels[channel.network]:
                    AllChannels[channel.network].append(channel.channel)
    for network in list(AllUsers.keys()):
        if network not in list(AllChannels.keys()):
            del AllUsers[network]
    for network in list(AllChannels.keys()):
        #hexchat.find_context().prnt('scanning ' + AllChannels[network][0] + ' at ' + network)
        hexchat.find_context(server=network).command('WHO ' + AllChannels[network][0])
        ScanProgress[network] = AllChannels[network][0]
    return 1 # To keep the timer running
Пример #2
0
def recv_notice_cb(word, word_eol, userdata):
	global last_context_name
	context_name = None
	nick = word[0][1:].split('!')[0]
	to = word[2]
	if to.startswith('#'):
		return hexchat.EAT_NONE
	if nick == 'ChanServ':
		if word[3].startswith(':[#') and word[3].endswith(']'):
			context_name = word[3][2:-1]
		elif word[3].startswith(':+[#') and word[3].endswith(']'):
			context_name = word[3][3:-1]
		elif word_eol[3].startswith(':Deopped you on channel ') and word_eol[3].endswith(' because it is registered with channel services'):
			context_name = hexchat.strip(word[7])
		elif word_eol[3] == ':and you are not a CHANOP on its access list.':
			context_name = last_context_name
	if not context_name:
		context_name = nick
	if context_name:
		context = hexchat.find_context(server=hexchat.get_info('server'), channel=context_name)
		if not context:
			if context_name.startswith('#'):
				return hexchat.EAT_NONE
			else:
				hexchat.command('QUERY -nofocus %s' % context_name)
			context = hexchat.find_context(server=hexchat.get_info('server'), channel=context_name)
		if context:
			context.set()
			last_context_name = context_name
		else:
			last_context_name = None
Пример #3
0
def find_requesttab():
    context = hexchat.find_context(channel=tab_name)
    if context == None:
        hexchat.command("NEWSERVER -noconnect {0}".format(tab_name))
        return hexchat.find_context(channel=tab_name)
    else:
        return context
Пример #4
0
def find_adtab():
    context = hexchat.find_context(channel=tab_name)
    if context is None:
        hexchat.command("NEWSERVER -noconnect {0}".format(tab_name))
        return hexchat.find_context(channel=tab_name)
    else:
        return context
Пример #5
0
def get_error_context():
    global _use_error_context, _err_context_name
    if not _use_error_context:
        return hexchat.get_context()
    ctx = hexchat.find_context(server=_err_context_name)
    if ctx is None:
        hexchat.command('newserver -noconnect "{}"'.format(_err_context_name))
        ctx = hexchat.find_context(server=_err_context_name)
    return ctx
Пример #6
0
def get_error_context():
    global _use_error_context, _err_context_name
    if not _use_error_context:
        return hexchat.get_context()
    ctx = hexchat.find_context(server=_err_context_name)
    if ctx is None:
        hexchat.command('newserver -noconnect "{}"'.format(_err_context_name))
        ctx = hexchat.find_context(server=_err_context_name)
    return ctx
Пример #7
0
def Redirect(word, word_eol, userdata):
    if hexchat.get_info("channel").lower() == channel and len(word) > 2 and word[2] == "%":
        tabContext = hexchat.find_context(channel=newTab)
        if tabContext is None:
            MakeTab()
            tabContext = hexchat.find_context(channel=newTab)
        tabContext.emit_print("Channel Message", word[0], word[1], word[2])
        return hexchat.EAT_ALL
    else:
        return hexchat.EAT_NONE
Пример #8
0
def findLogTab():
	context = hexchat.find_context(channel=LOG_TAB)
	if context == None: # Create a new one in the background
		newtofront = hexchat.get_prefs('gui_tab_newtofront')
		hexchat.command('set -quiet gui_tab_newtofront 0')
		hexchat.command('newserver -noconnect {0}'.format(LOG_TAB))
		hexchat.command('set -quiet gui_tab_newtofront {}'.format(newtofront))
		return hexchat.find_context(channel=LOG_TAB)
	else:
		return context	
Пример #9
0
def Redirect(word, word_eol, userdata):
    if hexchat.get_info(
            "channel").lower() == channel and len(word) > 2 and word[2] == "%":
        tabContext = hexchat.find_context(channel=newTab)
        if tabContext is None:
            MakeTab()
            tabContext = hexchat.find_context(channel=newTab)
        tabContext.emit_print("Channel Message", word[0], word[1], word[2])
        return hexchat.EAT_ALL
    else:
        return hexchat.EAT_NONE
Пример #10
0
def find_log_tab():
    """ Create separate tab for debugging messages """
    context = hexchat.find_context(channel=LOG_CONTEXT_NAME)
    if context == None:
        newtofront = hexchat.get_prefs('gui_tab_newtofront')
        
        hexchat.command('set -quiet gui_tab_newtofront 0')
        hexchat.command('newserver -noconnect {0}'.format(LOG_CONTEXT_NAME))
        hexchat.command('set -quiet gui_tab_newtofront {}'.format(newtofront))
        return hexchat.find_context(channel=LOG_CONTEXT_NAME)
    else:
        return context
Пример #11
0
def find_highlighttab(arg1):
    context = hexchat.find_context(channel=arg1)
    if context == None:
        newtofront = hexchat.get_prefs('gui_tab_newtofront')

        hexchat.command('set -quiet gui_tab_newtofront 0')
        hexchat.command('newserver -noconnect {0}'.format(arg1))
        hexchat.command('set -quiet gui_tab_newtofront {}'.format(newtofront))

        return hexchat.find_context(channel=arg1)
    else:
        return context
Пример #12
0
def find_highlighttab():
    context = hexchat.find_context(channel=TAB_NAME)
    if context == None:  # Create a new one in the background
        newtofront = hexchat.get_prefs('gui_tab_newtofront')

        hexchat.command('set -quiet gui_tab_newtofront 0')
        hexchat.command('newserver -noconnect {0}'.format(TAB_NAME))
        hexchat.command('set -quiet gui_tab_newtofront {}'.format(newtofront))

        return hexchat.find_context(channel=TAB_NAME)
    else:
        return context
Пример #13
0
def highlights_tab():
    """
    Function which will return context of tab for logging highlights. If the tab does not exist, it
    is created.
    """
    context = hexchat.find_context(channel=HIGHLIGHTS_TAB)
    if context is None:
        newtofront = hexchat.get_prefs('gui_tab_newtofront')
        hexchat.command('set -quiet gui_tab_newtofront 0')
        hexchat.command('newserver -noconnect {}'.format(HIGHLIGHTS_TAB))
        hexchat.command('set -quiet gui_tab_newtofront {}'.format(newtofront))
        context = hexchat.find_context(channel=HIGHLIGHTS_TAB)
    return context
Пример #14
0
def commandLog(w, we, u):
    context = hexchat.find_context(channel=logTab)
    if context:
        context.command("clear")
        context.command("gui focus")
    else:
        oldSetting = hexchat.get_prefs("gui_tab_newtofront")
        hexchat.command("set -quiet gui_tab_newtofront 1")
        hexchat.command("query " + logTab)
        hexchat.command("set -quiet gui_tab_newtofront " + str(oldSetting))
        context = hexchat.find_context(channel=logTab)
    for t, entry in logHistory:
        context.prnt(time.strftime("[%H:%M:%S] ", t) + entry)
    return hexchat.EAT_ALL
Пример #15
0
def query_line(message):
    """Writes a single line to the private script channel tagged as
    "GatoScript". Usefull to send short messages without mixing/lossing them
    in the conversation.
    Arguments:
    message -- message string
    """
    orig_context = hexchat.get_context()
    context = hexchat.find_context(channel="GatoScript")
    if context is None:
        hexchat.command("query -nofocus GatoScript")
        context = hexchat.find_context(channel="GatoScript")
    context.emit_print("Private Message", "GatoScript", message)
    orig_context.set()
Пример #16
0
def commandLog(w, we, u):
    context = hexchat.find_context(channel = logTab)
    if context:
        context.command("clear")
        context.command("gui focus")
    else:
        oldSetting = hexchat.get_prefs("gui_tab_newtofront")
        hexchat.command("set -quiet gui_tab_newtofront 1")
        hexchat.command("query " + logTab)
        hexchat.command("set -quiet gui_tab_newtofront " + str(oldSetting))
        context = hexchat.find_context(channel = logTab)
    for t, entry in logHistory:
        context.prnt(time.strftime("[%H:%M:%S] ", t) + entry)
    return hexchat.EAT_ALL
Пример #17
0
def load_session():
	for pref in hexchat.list_pluginpref():
		if len(pref) > 8 and pref[:8] == 'session_':
			network = pref[8:]
			channels = hexchat.get_pluginpref('session_' + network).split(',')
			hexchat.command('url irc://"{}"/'.format(network)) # Using url avoids autojoin
			hexchat.find_context(server=network).set()
			delay = hexchat.get_prefs('irc_join_delay') + 10
			for chan in channels:
				if chan[0] != '#':
					hexchat.command('timer {} query -nofocus {}'.format(delay, chan))
				else:
					hexchat.command('timer {} join {}'.format(delay, chan))

			hexchat.del_pluginpref('session_' + network)
Пример #18
0
def query_print(messages):
    """Writes multiple lines to the private script channel tagged as
    "GatoScript". Usefull to send long messages without mixing/lossing them
    in the conversation.
    Arguments:
    messages -- list of string
    """
    orig_context = hexchat.get_context()
    context = hexchat.find_context(channel="GatoScript")
    if context is None:
        hexchat.command("query -nofocus GatoScript")
        context = hexchat.find_context(channel="GatoScript")
    for message in messages:
        context.emit_print("Private Message", "GatoScript", message)
    orig_context.set()
Пример #19
0
def unload_callback(userdata):
    # find the join/part tab and close it
    for chan in hexchat.get_list("channels"):
        if chan.type == 1 and chan.channel == tab_name:
            jp_context = hexchat.find_context(channel=tab_name)
            jp_context.command("CLOSE")
    hexchat.prnt(__module_name__ + " version " + __module_version__ + " unloaded")
Пример #20
0
    def set_topic(self):
        """
        Set the channel topic (no formatting) and print the topic locally with formatting
        """

        #statusLong = "\00320\002OFF\002\00399"
        statusShort = get_pref("bullet_offline")
        if self.status == 1:
            #statusLong = "\00319\002ON\002\00399"
            statusShort = get_pref("bullet_online")


        if get_pref("modify_topic") == 1:
            msg = "{1}\00318{0}\00399 | {3} | \00318{2}\00399"\
                .format(self.display_name, statusShort, self.game, self.title)

            # HexChat doesn't support hiding characters in the topic bar (Windows), so strip the formatting until it's fixed
            if sys.platform == "win32":
                msg = hexchat.strip(msg, -1, 3)

            if hexchat.get_info("topic") != msg:
                hexchat.command("RECV :[email protected] TOPIC #{0} :{1}".format(self.channel, msg))


        if get_pref("modify_tab") == 1:
            # Set the tab title to the properly capitalized form of the name
            settabCommand = "SETTAB {0}{1}"\
                .format(statusShort, self.display_name)
            hashChannel = "#{0}".format(self.channel)

            cxt = hexchat.find_context(hexchat.get_info("server"), hashChannel)
            if not cxt == None:
                cxt.command(settabCommand)
Пример #21
0
def print_day_changed():
    date_fmt = '%a %d %b %Y (%Y-%m-%d)'
    date = datetime.now().strftime(date_fmt)
    channel_list = hexchat.get_list("channels")
    for item in channel_list:
        context = hexchat.find_context(channel=item.channel)
        context.prnt('\002\00315Day changed to {}'.format(date))
Пример #22
0
def toggle_bookmark(chan, net): # It's a toggle because /menu sucks
	if chan == None:
		chan = hexchat.get_info('channel')

	if chan == '':
		return

	if net == None:
		try: # If from a $TAB it may be a different network.
			net = hexchat.find_context(None, chan).get_info('network')
		except AttributeError:
			net = hexchat.get_info('network')

	for channel in hexchat.get_list('channels'):
		if channel.channel == chan:
			if channel.type != 2: # Only bookmark channels
				return
				
	networks = get_networks(chan)
	pref = 'bookmark_' + chan
	if net in networks: # Remove
		if len(networks) == 1:
			hexchat.del_pluginpref(pref)
		else:
			networks.remove(net)
			hexchat.set_pluginpref(pref, ','.join(networks))
		hexchat.command('menu del "Bookmarks/{}/{}"'.format(net, chan))
	else: # Add
		networks.append(net)
		hexchat.set_pluginpref(pref, ','.join(networks))
		hexchat.command('menu -p-2 add "Bookmarks/{}'.format(net))
		hexchat.command('menu add "Bookmarks/{0}/{1}" "netjoin {1} {0}"'.format(net, chan))
Пример #23
0
def send_notice_cb(word, word_eol, userdata):
	global send_notice_hook
	to = word[1]
	context = hexchat.find_context(server=hexchat.get_info('server'), channel=to)
	if not context:
		if to.startswith('#'):
			return hexchat.EAT_NONE
		else:
			hexchat.command('QUERY -nofocus %s' % to)
		context = hexchat.find_context(server=hexchat.get_info('server'), channel=to)
	if context:
		context.set()
		hexchat.unhook(send_notice_hook)
		context.command(word_eol[0])
		send_notice_hook = hexchat.hook_command("NOTICE", send_notice_cb)
		return hexchat.EAT_ALL
Пример #24
0
    def doInfo(self, cmdString, argList, kwargs):
        result = 0

        top_context = hexchat.find_context()
        channel_list = hexchat.get_list('channels')
        front_tab = [
            c for c in hexchat.get_list('channels') if c.context == top_context
        ][0]
        type = front_tab.type

        if type == 1:
            # server tab
            print("server tab, server is", front_tab.server)
        elif type == 2:
            # channel tab
            print("channel tab, channel is %s, modes are %s" %
                  (front_tab.channel, front_tab.chanmodes))
            users = top_context.get_list("users")
        elif type == 3:
            # dialog/query tab
            print("query tab, nick is", front_tab.channel)
        elif type == 4:
            # notices tab
            print("notices tab")
        elif type == 5:
            # SNotices tab
            print("SNotices tab")

        return result
Пример #25
0
Файл: icu.py Проект: lf94/ICU
def icu(word, word_eol, userdata):
    if len(word) < 4:
        hexchat.prnt(__module_help_message__)
        return hexchat.EAT_ALL
    
    contexts = userdata
    this_context = hexchat.get_context()
    operation = word[1]
    direction = word[2]
    destination = word[3]
    
    potential_context = hexchat.find_context(channel=destination)
    if potential_context == None:
        hexchat.prnt("Could not find {}.".format(destination))
        return hexchat.EAT_ALL

    if operation == "add":
        if direction == "to":
            contexts["to"].append(potential_context)
        elif direction == "from":
            contexts["from"].append(potential_context)
        this_context.prnt("Added relay {} {}".format(direction, destination))

    if operation == "del":
        if direction == "to":
            contexts["to"].remove(potential_context)
        elif direction == "from":
            contexts["from"].remove(potential_context)
        this_context.prnt("Deleted relay {} {}".format(direction, destination))

    return hexchat.EAT_ALL
Пример #26
0
 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
Пример #27
0
def toggle_bookmark(chan, net): # It's a toggle because /menu sucks
	if chan == None:
		chan = hexchat.get_info('channel')

	if chan == '':
		return

	if net == None:
		try: # If from a $TAB it may be a different network.
			net = hexchat.find_context(None, chan).get_info('network')
		except AttributeError:
			net = hexchat.get_info('network')

	for channel in hexchat.get_list('channels'):
		if channel.channel == chan:
			if channel.type != 2: # Only bookmark channels
				return
				
	networks = get_networks(chan)
	pref = 'bookmark_' + chan
	if net in networks: # Remove
		if len(networks) == 1:
			hexchat.del_pluginpref(pref)
		else:
			networks.remove(net)
			hexchat.set_pluginpref(pref, ','.join(networks))
		hexchat.command('menu del "Bookmarks/{}/{}"'.format(net, chan))
	else: # Add
		networks.append(net)
		hexchat.set_pluginpref(pref, ','.join(networks))
		hexchat.command('menu -p-2 add "Bookmarks/{}'.format(net))
		hexchat.command('menu add "Bookmarks/{0}/{1}" "netjoin {1} {0}"'.format(net, chan))
Пример #28
0
def ask8ball(word, word_to_eol, userdata):
    if len(word) == 1:
        say('/help 8ball')
    context = hexchat.find_context()
    #Magic8Ball... will this malware be more effective if it has a fancy GUI? ... 'Outlook good'
    context.prnt("Magic8Ball... {}? .. '{}'".format(' '.join(word[1:]), choice(_8ball_answers)))
    return hexchat.EAT_ALL
Пример #29
0
def icu(word, word_eol, userdata):
    if len(word) < 4:
        hexchat.prnt(__module_help_message__)
        return hexchat.EAT_ALL

    contexts = userdata
    this_context = hexchat.get_context()
    operation = word[1]
    direction = word[2]
    destination = word[3]

    potential_context = hexchat.find_context(channel=destination)
    if potential_context == None:
        hexchat.prnt("Could not find {}.".format(destination))
        return hexchat.EAT_ALL

    if operation == "add":
        if direction == "to":
            contexts["to"].append(potential_context)
        elif direction == "from":
            contexts["from"].append(potential_context)
        this_context.prnt("Added relay {} {}".format(direction, destination))

    if operation == "del":
        if direction == "to":
            contexts["to"].remove(potential_context)
        elif direction == "from":
            contexts["from"].remove(potential_context)
        this_context.prnt("Deleted relay {} {}".format(direction, destination))

    return hexchat.EAT_ALL
Пример #30
0
def dice(word, word_to_eol, userdata):
    if len(word) == 1:
        say('//help dice')
    roll_expr = ''.join(word[1:])
    context = hexchat.find_context()
    context.command('me {}'.format("rolls {}: {}".format(roll_expr, x(roll_expr).expr())))
    return hexchat.EAT_ALL
Пример #31
0
def daily_ohayou():
	global context
	if context == 0:
		context=hexchat.find_context(server="Rizon", channel="#yukkuri")
		context.set()
	say(".ohayou")
	start_timer()
Пример #32
0
def incomingping(word, word_eol, userdata):
    hexchat.command("query -nofocus >>pings<<")
    con = hexchat.find_context(server=hexchat.get_info("network"),
                               channel=">>pings<<")
    con.emit_print("Channel Message", word[0], word[1],
                   "", "{}/".format(hexchat.get_info("channel")))
    return hexchat.EAT_NONE
Пример #33
0
def daily_ohayou():
    global context
    if context == 0:
        context = hexchat.find_context(server="Rizon", channel="#yukkuri")
        context.set()
    say(".ohayou")
    start_timer()
Пример #34
0
def next_XDCC(bot_name=None):
	global glob_queue
	global downloading
	if len(glob_queue) > 0:
		rizon = hexchat.find_context(server="irc.rizon.net")
		rizon.command("query %s" % glob_queue[0][0])
		rizon.command("msg %s \00316\026\035\00301xdcc send \017\00316\026\00301\002#%s" % (glob_queue[0][0],glob_queue[0][1]))
		this_bot = glob_queue[0][0]
		glob_queue.pop(0)
		if len(glob_queue) > 0:
			string = "\00310\002Yui>\017 Remaining packs in \00302%s\017's queue: \002" % this_bot
			has_packs_remaining = False
			for queued_item in glob_queue:
				if queued_item[0] == this_bot:
					has_packs_remaining = True
					string = string + "#%s, " % queued_item[1]
			string = string[:-2]
			if has_packs_remaining:
				print(string)
			else:
				print("\00310\002Yui>\017 No more packs in \00302%s\017's queue!" %this_bot)
		else:
			print("\00310\002Yui>\017 No more packs in XDCC queue!")
	else:
		print("\00310\002Yui>\017 XDCC queue is empty!")
	
	return
Пример #35
0
def unload_cb(userdata):
    for chan in hexchat.get_list("channels"):
        if chan.type == 1 and chan.channel == tab_name:
            ad_context = hexchat.find_context(channel=tab_name)
            ad_context.command("CLOSE")
    hexchat.prnt(__module_name__ + " version " + __module_version__ +
                 " unloaded")
Пример #36
0
    def doInfo(self, cmdString, argList, kwargs):
        result = 0

        top_context = hexchat.find_context()
        channel_list = hexchat.get_list('channels')
        front_tab = [c for c in hexchat.get_list('channels') if c.context == top_context][0]
        type = front_tab.type

        if type == 1:
            # server tab
            print("server tab, server is", front_tab.server)
        elif type == 2:
            # channel tab
            print("channel tab, channel is %s, modes are %s" % (front_tab.channel, front_tab.chanmodes))
            users = top_context.get_list("users")
        elif type == 3:
            # dialog/query tab
            print("query tab, nick is", front_tab.channel)
        elif type == 4:
            # notices tab
            print("notices tab")
        elif type == 5:
            # SNotices tab
            print("SNotices tab")

        return result
Пример #37
0
def autoback_cb(word, word_eol, userdata):

    with AutobackConfig() as autoback:
        enabled = autoback.enabled

    if enabled:
        current_network = hexchat.get_info("network")
        with NetworkList() as networks:
            away_networks = list(networks._get_away())

        if current_network in away_networks:
            # "AutobackConfig(1)", 1 to increment .talk_count
            with AutobackConfig(1) as autoback:
                hexchat.prnt(str_prefix + \
                    "\002warning:\002 you've talked " + \
                        "\002{}\002/\002{}\002 times while away.".format(
                            autoback.talk_count, autoback.threshold))
                if autoback.talk_count >= autoback.threshold:
                    hexchat.prnt(str_prefix + \
                        "You will be set back on network \002{}\002".format(
                            current_network))
                    autoback.talk_count = 0
                    suffix = hexchat.get_pluginpref("hcaway_suffix")
                    context = hexchat.find_context(server=current_network)
                    context.command("nick {}".format(
                        context.get_info("nick").replace(suffix, "")))
                    context.command("back")

    return hexchat.EAT_NONE
Пример #38
0
def hcaway_cb(word, word_eol, userdata):
    away_time, reason = time.strftime("%H:%M (%b %d %Y) %z"), ""
    suffix = hexchat.get_pluginpref("hcaway_suffix")

    away_string = "'{}' at {}".format(__module_fullname__, away_time)
    if len(word) > 1:
        away_string = "'{}' at {}".format(word_eol[1], away_time)
        reason = " reason: \"{}\"".format(word_eol[1])

    with NetworkList() as networks:
        # networks that the user is not away on
        whitelist = list(networks._get_back())
        for network in whitelist:
            context = hexchat.find_context(server=network)
            context.command("nick {}{}".format(
                context.get_info("nick"), suffix))
            context.command("away " + away_string)

    if len(whitelist) >= 1:
        hexchat.prnt(str_prefix + "you're now away on \002{}\002.{}".format(
            ("\002, \002".join(whitelist[0:-1]) + "\002 and \002" + \
                whitelist[-1]) if len(whitelist) > 1 else (whitelist[0]), 
                    reason))
    else:
        error("either you've no networks added to your whitelist, "
            "or you're already away on one or more of them.")

    return hexchat.EAT_ALL
Пример #39
0
def sendmsg(word, word_eol, userdata):
    "Function called by /gpg. Parses user input, encrypts, and sends."
    channel = hexchat.get_info("channel")
    context = hexchat.find_context(channel=channel)
    if not userdata and len(word) < 3:
        context.emit_print("Channel Message", __module_name__, help_gpg)
        return hexchat.EAT_ALL
    elif userdata and len(word) < 4:
        context.emit_print("Channel Message", __module_name__, help_gpgs)
        return hexchat.EAT_ALL
    # Waiting for gpg-agent.exe to start and encrypt causes HexChat to hang.
    # Requires further testing with large messages.
    if not userdata:
        data = encrypt_message(word[1], None, word_eol[2], None)
    elif userdata and "s" in userdata:
        data = encrypt_message(word[1], word[2], word_eol[3], userdata)
    data = data.split("\n")
    for line in range(len(data)):
        data[line] = data[line].replace("\r", "")
        if data[line]: # Don't send blank lines
            context.emit_print(
                "Channel Message", hexchat.get_info("nick"), data[line]
            )
            context.command(
                "PRIVMSG {0} {1}".format(channel, data[line])
            )
    return hexchat.EAT_ALL
Пример #40
0
 def run(self):
     url = post_to_gist('Content posted in %s' % self.channel, self.data)
     c = hexchat.find_context(self.server, self.channel)
     if c:
         c.command('msg %s %s' % (self.channel, PASTE_MESSAGE % url))
     else:
         print('%s\tCould not find context for %s%s, maybe you closed it?' %
               (__module_name__, self.server, self.channel))
Пример #41
0
 def find(cls, server=None, channel=None, id=None):
     if id is None:
         return cls._make(hexchat.find_context(server, channel))
     channel = channel.lower()
     for ch in hexchat.get_context().get_list('channels'):
         if ch.id == id and ch.channel == channel:
             return cls(ch.context)
     return None
Пример #42
0
 def find(cls, server=None, channel=None, id=None):
     if id is None:
         return cls._make(hexchat.find_context(server, channel))
     channel = channel.lower()
     for ch in hexchat.get_context().get_list('channels'):
         if ch.id == id and ch.channel == channel:
             return cls(ch.context)
     return None
Пример #43
0
def unload_callback(userdata):
    # find the join/part tab and close it
    for chan in hexchat.get_list("channels"):
        if chan.type == 1 and chan.channel == tab_name:
            jp_context = hexchat.find_context(channel=tab_name)
            jp_context.command("CLOSE")
    hexchat.prnt(__module_name__ + " version " + __module_version__ +
                 " unloaded")
Пример #44
0
def say(channel):
    channel_context = hexchat.find_context(channel=channel)

    sleep_delay = random.randint(4, 15)
    time.sleep(sleep_delay)

    command = 'msg {} .bef'.format(channel)
    channel_context.command(command)
Пример #45
0
def load_session():
    for pref in hexchat.list_pluginpref():
        if len(pref) > 8 and pref[:8] == 'session_':
            network = pref[8:]
            channels = hexchat.get_pluginpref('session_' + network).split(',')
            hexchat.command(
                'url irc://"{}"/'.format(network))  # Using url avoids autojoin
            hexchat.find_context(server=network).set()
            delay = hexchat.get_prefs('irc_join_delay') + 10
            for chan in channels:
                if chan[0] != '#':
                    hexchat.command('timer {} query -nofocus {}'.format(
                        delay, chan))
                else:
                    hexchat.command('timer {} join {}'.format(delay, chan))

            hexchat.del_pluginpref('session_' + network)
Пример #46
0
def loadpm_cb(word, word_eol, userdata):
    #TODO: save dialogs to a single user across multiple networks
    for pref in hexchat.list_pluginpref():
        if pref[:10] == "persistpm_":
            saved_network = hexchat.get_pluginpref(pref)
            if saved_network == hexchat.get_info("network"):
                saved_nick = pref[10:]
                network_context = hexchat.find_context(channel=saved_network)
                network_context.command("QUERY {}".format(saved_nick))
Пример #47
0
def highlight_callback(word, word_eol, user_data):
	global tab_name
	
	word = [(word[i] if len(word) > i else '') for i in range(4)]
	
	highlight_context = hexchat.find_context(channel=tab_name)
	if highlight_context is None:
		create_highlighttab()
		highlight_context = hexchat.find_context(channel=tab_name)
	
	channel = hexchat.get_info('channel')
	
	if user_data == 'Channel Msg Hilight':
		highlight_context.emit_print('Channel Message', channel, '<{3}{2}{0}> {1}'.format(word[0], word[1], word[2], word[3]), '', '')
	elif user_data == 'Channel Action Hilight':
		highlight_context.emit_print('Channel Action', channel, '{3}{2}{0} {1}'.format(word[0], word[1], word[2], word[3]), '', '')
	
	return hexchat.EAT_NONE
Пример #48
0
def time_cb(txt):
    global week
    global hook
    channel = hexchat.find_context(channel='#xshellz')
    channel.command('say {1} {0}'.format(username,txt))
    update()
    if hook:
        hexchat.unhook(hook)
    hook = hexchat.hook_timer((week*1000),time_cb,userdata='!keep')
Пример #49
0
def quit_cb(word, word_eol, userdata):
	networks = {}

	for chan in hexchat.get_list('channels'):
		if chan.type == 2 or chan.type == 3: # Ignore notices and server tabs
			if not chan.network in networks:
				networks[chan.network] = []
			if (chan.channelkey):
				networks[chan.network].append(chan.channel + ' ' + chan.channelkey)
			else:
				networks[chan.network].append(chan.channel)

	for network, channels in networks.items():
		hexchat.set_pluginpref('session_' + network, ','.join(channels))
		hexchat.find_context(server=network).command('quit')
		
	hexchat.command('timer 1 killall')
	return hexchat.EAT_ALL
Пример #50
0
def log(level, string):
    t = time.localtime()
    entry = logPrefixes[level] + string
    logHistory.append((t, entry))
    if level >= logLevel and hexchat.get_info("channel") != logTab:
        hexchat.prnt(entry)
    context = hexchat.find_context(channel=logTab)
    if context:
        context.prnt(time.strftime("[%H:%M:%S] ", t) + entry)
Пример #51
0
def modechange(word, word_eol, userdata):
    if hexchat.get_info("network").lower() == "snoonet":
        if "#" in word[2]:
            if len(word[3]) > 5:
                hexchat.command("query -nofocus >>modes<<")
                modecon = hexchat.find_context(None, ">>modes<<")
                modecon.emit_print("Raw Modes", "{}/{}".format(
                    word[0].split("!")[0][1:], word[2]), word_eol[3])
    return hexchat.EAT_NONE
Пример #52
0
def log(level, string):
    t = time.localtime()
    entry = logPrefixes[level] + string
    logHistory.append((t, entry))
    if level >= logLevel and hexchat.get_info("channel") != logTab:
        hexchat.prnt(entry)
    context = hexchat.find_context(channel = logTab)
    if context:
        context.prnt(time.strftime("[%H:%M:%S] ", t) + entry)
Пример #53
0
def clearstatus(word, word_eol, userdata):
    anyLeft = 1
    while anyLeft == 1:
        try:
            statusContexts = hexchat.find_context(
                channel='{0}status'.format(zncPrefix))
            statusContexts.command("close")
        except AttributeError:
            anyLeft = 0
    return hexchat.EAT_ALL
Пример #54
0
def quit_cb(word, word_eol, userdata):
    networks = {}

    for chan in hexchat.get_list('channels'):
        if chan.type == 2 or chan.type == 3:  # Ignore notices and server tabs
            if not chan.network in networks:
                networks[chan.network] = []
            if (chan.channelkey):
                networks[chan.network].append(chan.channel + ' ' +
                                              chan.channelkey)
            else:
                networks[chan.network].append(chan.channel)

    for network, channels in networks.items():
        hexchat.set_pluginpref('session_' + network, ','.join(channels))
        hexchat.find_context(server=network).command('quit')

    hexchat.command('timer 1 killall')
    return hexchat.EAT_ALL
Пример #55
0
def printStuff():
    """
    Display all messages in queue and saves the last timestamp.

    If there are multiple messages, they are sorted by time.
    """
    global messages

    count = len(messages)

    # if no hls, no need to do stuff
    if count == 0:
        return

    # Sort by time if there is more than one
    if count != 1:
        messages.sort(key=lambda t: t[0])

    # Get the tab if it exists
    ctx = hexchat.find_context('', '')

    if not ctx:
        # Or create a new one
        hexchat.command('newserver -noconnect')
        ctx = hexchat.find_context('', '')
        ctx.command('settab %s' % TAB_NAME)

    for message in messages:
        ctx.emit_print('Generic Message',
                       message[1],
                       message[2],
                       time=message[0])

    if count:
        # Reset the messages
        messages = []
        # Color the hl tab
        ctx.command('gui color 3')
        # and save the last_hl
        hexchat.set_pluginpref(PREF, last_hl)

    return
Пример #56
0
def on_rh_nick(word, word_eol, userdata):
    """
    Callback function which changes nickname, but only on server/network 'RedHat'.

    Command usage:
        /rh-nick new_nick
    """
    new_nick = word[1]
    rh = hexchat.find_context(server='RedHat')
    rh.command('nick {}'.format(new_nick))
    return hexchat.EAT_HEXCHAT
Пример #57
0
def whisper_cb(word, word_eol, userdata):
    whisper = word_eol[3].replace(':', '', 1)
    nick = word[0][1:].split('!')[0]
    context = hexchat.find_context(channel=nick)
    if context:
        context.command('recv {} PRIVMSG {}'.format(word[0], word_eol[2]))
    else:
        # hexchat.command('recv {} NOTICE {}'.format(word[0], word_eol[2]))
        # 'Private Message' produces a beep so is preferable
        hexchat.emit_print('Private Message', nick, whisper)
    return hexchat.EAT_ALL