Exemplo n.º 1
0
def prefs(job, args=None):
    """Saves|Gets preferences."""
    if job == 'get':
        status = xchat.get_pluginpref("shorten_status")

        # Get data from database
        if not status: return True
        else:
            if status == 'on': return True
            else: return False
    if job == 'put' and args:
        xchat.set_pluginpref("shorten_status", args)
        xchat.prnt("Preferences saved.")
Exemplo n.º 2
0
def decipher_youtube_url(url, nick, orig_msg, dest=None):
	try:
		for line in urlopen(url):
			line = line.decode('utf-8')
			if line.startswith("<title>"):
				title = unescape(re.sub(r"^<title>(.*) - YouTube</title>.*",r"\1",line))
				msg = format_msg(nick,url,title)
				sending_msg = xchat.get_pluginpref(SENDING_MSG_PREF)
				not sending_msg and xchat.set_pluginpref(SENDING_MSG_PREF,"no") 
				DEBUG and xchat.prnt(__module_name__+": "+SENDING_MSG_PREF+": "+sending_msg)
				if sending_msg != None and dest != None and sending_msg == "yes" and not msg_containing_word_of_title(orig_msg,title):
					DEBUG and xchat.prnt(__module_name__+": sending msg")
					xchat.command("msg "+dest+" "+ msg)
				else:
					xchat.prnt(msg)
	except BaseException as e:
		xchat.prnt(__module_name__+" failed to decipher : "+url+" error: "+e.__str__())
Exemplo n.º 3
0
__module_name__ = 'Regex Replace'
__module_version__ = '1.0'
__module_description__ = 'Replaces matching regex patterns'

import re
import ast
import shlex
import xchat


# Load saved patterns
re_pattern = xchat.get_pluginpref("autoreplace_re_pattern")
re_repl = xchat.get_pluginpref("autoreplace_re_repl")

# If previous patterns are found, convert the string to a list.
# Otherwise, create an empty list.
if re_pattern is not None and re_repl is not None:
    re_pattern = ast.literal_eval(re_pattern)
    re_repl = ast.literal_eval(re_repl)
else:
    re_pattern = []
    re_repl = []


def send_message(word, word_eol, userdata):
    """Gets the inputbox's text, perform substitutions and replaces it.

    This function is called every time a key is pressed. It will stop if that
    key isn't Enter or if the input box is empty.

    KP_Return (keypad Enter key) is ignored, and can be used if you don't want
Exemplo n.º 4
0
__module_description__ = ("Specifies nick colors")
# Partially based on tingping's wordhilight and alias

#Settings!
trigger_for = [
    'Channel Message',
    'Channel Action',
]
setting_prefix = "specifycolor_"

#load settings
users = dict()
for pref in xchat.list_pluginpref():
    if pref.startswith(setting_prefix):
        name = pref[len(setting_prefix):]
        users[name] = xchat.get_pluginpref(setting_prefix + name)

# remove ^K, ^K##, ^K##,##
stripper = re.compile(r'^\003(\d\d?(,\d\d?)?)?')

edited = False


def decolor_cb(word, word_eol, event, attr):
    global edited
    nick = stripper.sub('', word[0])
    #Ignore our own events, empty messages, and
    # other things that don't concern us
    #note: nickcmp should probably be used, but I want to stay sane
    #and might not work in python2
    if edited or not len(word) > 1 or nick.lower() not in users.keys():
Exemplo n.º 5
0
__module_name__ = 'Regex Replace'
__module_version__ = '1.0'
__module_description__ = 'Replaces matching regex patterns'

import re
import ast
import shlex
import xchat

# Load saved patterns
re_pattern = xchat.get_pluginpref("autoreplace_re_pattern")
re_repl = xchat.get_pluginpref("autoreplace_re_repl")

# If previous patterns are found, convert the string to a list.
# Otherwise, create an empty list.
if re_pattern is not None and re_repl is not None:
    re_pattern = ast.literal_eval(re_pattern)
    re_repl = ast.literal_eval(re_repl)
else:
    re_pattern = []
    re_repl = []


def send_message(word, word_eol, userdata):
    """Gets the inputbox's text, perform substitutions and replaces it.

    This function is called every time a key is pressed. It will stop if that
    key isn't Enter or if the input box is empty.

    KP_Return (keypad Enter key) is ignored, and can be used if you don't want
    any substitutions to happen.