def set_key_type(self, word, word_eol, userdata): target = xchat.get_info('channel') server = xchat.get_info('server') ktype = '' if len(word) == 2: ktype = word[1] elif len(word) >= 3: target = word[1] if len(word) == 3: ktype = word[2] else: server = word[2] ktype = word[3] try: key = self.keymap[target, server] except KeyError: print 'No key set for {} @ {}.'.format(target, server) else: if ktype.lower() in ['aes', 'a', 'blowfish', 'b']: key.aes = (ktype.lower() in ['aes', 'a']) print 'Key type for {} @ {} set to {}.'.format(target, server, key.get_type()) elif not ktype: print 'Key type for {} @ {} is {}.'.format(target, server, key.get_type()) else: print 'Key type must be either AES or Blowfish.' return xchat.EAT_ALL
def CheckWhoRet(word,word_eol,userdata): global hosts servChan = xchat.get_info("host")+"/"+xchat.get_info("channel") nick,user,host = (word[7],word[4],word[5]) if servChan not in hosts: hosts[servChan] = {} hosts[servChan][nick] = (user,host) return xchat.EAT_NONE
def handle_message(self, word, word_eol, userdata): ''' Handle a message in xchat. word is something like: [ '\xaaaanick', "the message we're acting on" ] where aaaa is a number like \x0328 This, incidentally, is not what the doc says it should be at http://xchat.org/docs/xchatpython.html userdata is something like: 'Channel Message', from EVENTS, so you can play different sounds depending on what happened. ''' # If it's too soon after startup, don't do anything. # Then we won't hear a slew of alerts from past scrollback, # NickServ 'You are now identified for" messages, etc. if time.time() - self.start_time < XchatSoundHandler.STARTUP_DELAY : return xchat.EAT_NONE # You may want to use channel name, network name or variables # in the xchat context to decide which alerts to play. channel = xchat.get_info('channel') network = xchat.get_info('network') ctxt = xchat.get_context() mynick = ctxt.get_info("nick") line = word[1] # Now, customize the rest as desired. Here are some examples: # Anyone addressing or mentioning my nick: if line.find(mynick) > 0 and word[0] != 'NickServ' or \ userdata == "Channel Msg Hilight" or \ userdata == "Channel Action Hilight" : # print ">>>>> Contains my nick!", userdata, ">>", line self.player.play(os.path.join(self.sound_dir, "akk.wav")) return xchat.EAT_NONE # Private message: elif userdata.startswith("Private Message") : # print ">>>>> Private message!" self.player.play(os.path.join(self.sound_dir, "akk.wav")) return xchat.EAT_NONE # Now check whether we're silenced. # Note that nick references and private messages are exempt # from this check -- you'll hear them even on silenced channels. if channel in self.silenced_channels : return xchat.EAT_NONE # More subtle sound for bitlbee/twitter, since they're so numerous: if channel == "#twitter_" + mynick : # print ">>>>> Twitter channel!" self.player.play(os.path.join(self.sound_dir, "SingleClick.wav")) # if you want to be fairly noisy or don't have many active channels, # you might want an alert for every channel message: elif userdata.startswith("Channel M") or \ userdata.startswith("Channel Action") : self.player.play(os.path.join(self.sound_dir, "pop.wav")) return xchat.EAT_NONE
def CheckCondition(cond, arg): if cond in ["ifuser", "ifnotuser"]: # EVERY CHANNEL LIKE A RETARD, XCHAT # WHY NOT JUST HAVE xchat.get_info("user") HUH? F**K YOU username = None serv = xchat.get_info("server") for ch in xchat.get_list("channels"): if ch.server == serv: nick = xchat.get_info("nick") for user in ch.context.get_list("users"): if user.nick == nick: # FURTHER TROLLING? username = user.host.split("@")[0].lstrip("~") break # endif # endfor # endif # endfor if not username: return False if "not" in cond: return arg != username else: return arg == username elif cond == "true": return True return False
def messagebuffer(dunno): global list_ #Makes sure we have locked the list so that we start on a new list if we send messages during execution tmplist = list_ list_ = None #Get's the current channel, so we know where we should send messages channel = xchat.get_info('channel') #If the list is shorter than the pastelimit, just send them one by one to the irc-server if len(tmplist) <= settings['limit']: for i in tmplist: #send the actual string xchat.command("PRIVMSG %s :%s" % (channel, i)) #recreate the output from a regular message, as this is just a regular message xchat.emit_print("Your Message", xchat.get_info('nick'), i, "@") else: #Add all the lines together into a string str_ = "" for i in tmplist: str_ += i + "\n" # do the paste pastie_url = do_pastie(str_[:-1]) xchat.command("PRIVMSG %s :%s" % (xchat.get_info('channel'), pastie_url)) xchat.emit_print("Your Message", xchat.get_info('nick'), pastie_url, "@") return 0 # Return 0 so we don't repeat the timer.
def cap_cb(word, word_eol, userdata): subcmd = word[3] caps = word[4:] caps[0] = caps[0][1:] if subcmd == 'LS': toSet = [] # Parse the list of capabilities received from the server if 'multi-prefix' in caps: toSet.append('multi-prefix') # Ask for the SASL capability only if there is a configuration for this network if 'sasl' in caps and conf.has_section(xchat.get_info('network')): toSet.append('sasl') if toSet: # Actually set capabilities xchat.command('CAP REQ :%s' % ' '.join(toSet)) else: # Sorry, nothing useful found, or we don't support these xchat.command('CAP END') elif subcmd == 'ACK': if 'sasl' in caps: xchat.command('AUTHENTICATE PLAIN') print("SASL authenticating") saslTimers[xchat.get_info('network')] = xchat.hook_timer( 5000, sasl_timeout_cb) # Timeout after 5 seconds # In this case CAP END is delayed until authentication ends else: xchat.command('CAP END') elif subcmd == 'NAK': xchat.command('CAP END') elif subcmd == 'LIST': if not caps: caps = 'none' print('CAP(s) currently enabled: %s') % ', '.join(caps) return xchat.EAT_XCHAT
def cap_cb(word, word_eol, userdata): subcmd = word[3] caps = word[4:] caps[0] = caps[0][1:] if subcmd == 'LS': toSet = [] # Parse the list of capabilities received from the server if 'multi-prefix' in caps: toSet.append('multi-prefix') # Ask for the SASL capability only if there is a configuration for this network if 'sasl' in caps and conf.has_section(xchat.get_info('network')): toSet.append('sasl') if toSet: # Actually set capabilities xchat.command('CAP REQ :%s' % ' '.join(toSet)) else: # Sorry, nothing useful found, or we don't support these xchat.command('CAP END') elif subcmd == 'ACK': if 'sasl' in caps: xchat.command('AUTHENTICATE PLAIN') print("SASL authenticating") saslTimers[xchat.get_info('network')] = xchat.hook_timer(15000, sasl_timeout_cb) # Timeout after 15 seconds # In this case CAP END is delayed until authentication ends else: xchat.command('CAP END') elif subcmd == 'NAK': xchat.command('CAP END') elif subcmd == 'LIST': if not caps: caps = 'none' print('CAP(s) currently enabled: %s') % ', '.join(caps) return xchat.EAT_XCHAT
def fake(word, word_eol, userdata): my_nick = xchat.get_info('nick') try: topic = word_eol[1] except: xchat.prnt("fake_log_image.py Error: Invalid arguments!" ) #add error func later else: nicklist = [xchat.strip(user.nick) for user in xchat.get_list('users')] network = xchat.get_info('network') chan = xchat.get_info('channel') fake_log_image_generator(nicklist, network, chan, my_nick, topic) if UPLOAD_TO_IMGUR: try: import pyimgur except ImportError: xchat.prnt( "[!] fake_log_image.py Error: pyimgur module not found!") else: client_id = '' im = pyimgur.Imgur(client_id) uploaded_image = im.upload_image( PATH + NEW_FILENAME, title="100 PERCENT AUTHENTIC REAL LOGS") lnk = uploaded_image.link lnk = lnk.replace('http', 'https') xchat.command("say I just took a screenshot of this chat: " + lnk) return xchat.EAT_ALL
def set_key_type(self, word, word_eol, userdata): target = xchat.get_info('channel') server = xchat.get_info('server') ktype = '' if len(word) == 2: ktype = word[1] elif len(word) >= 3: target = word[1] if len(word) == 3: ktype = word[2] else: server = word[2] ktype = word[3] try: key = self.keymap[target, server] except KeyError: print 'No key set for {} @ {}.'.format(target, server) else: if ktype.lower() in ['aes', 'a', 'blowfish', 'b']: key.aes = (ktype.lower() in ['aes', 'a']) print 'Key type for {} @ {} set to {}.'.format( target, server, key.get_type()) elif not ktype: print 'Key type for {} @ {} is {}.'.format( target, server, key.get_type()) else: print 'Key type must be either AES or Blowfish.' return xchat.EAT_ALL
def nickchange(word, word_eol, userdata): desired_nick = xchat.get_prefs("irc_nick1") password = xchat.get_info("nickserv") if xchat.get_info("nick") is desired_nick: lineprint("Got desired nick now: "+desired_nick) return SUCCESS return FAIL
def CheckWhoRet(word, word_eol, userdata): global hosts servChan = xchat.get_info("host") + "/" + xchat.get_info("channel") nick, user, host = (word[7], word[4], word[5]) if servChan not in hosts: hosts[servChan] = {} hosts[servChan][nick] = (user, host) return xchat.EAT_NONE
def dc801_channel(): print "dc801_channel" ''' Is this channel #dc801 on FreeNode? ''' global CHANNEL_NAME, NETWORK_NAME net = xchat.get_info("network") chan = xchat.get_info("channel") return net==NETWORK_NAME and chan==CHANNEL_NAME
def main(word, word_eol, userdata): channel = xchat.get_info("channel")[1:] if xchat.get_info("server") == "tmi.twitch.tv": server = "twitch.tv" else: server = defaultserver if len(word) == 1: connect(channel, quality, server) elif word[1] == "raw" and len(word) >= 3: xchat.command("exec livestreamer {0}".format(word_eol[2])) elif word[1] == "help" and len(word) >= 2: xstreamHelp(word, word_eol) elif any(word[1] == stopcmd for stopcmd in stopcommands) and len(word) == 2: if platform.system() == "Windows": xchat.command("exec taskkill /im livestreamer.exe /f") elif platform.system() == "Linux": xchat.command("exec pkill livestreamer") else: print("Sorry, I don't recognize your operating system") elif len(word) == 2: if word[1] == "stop": xchat.command("execkill") elif word[1] == "raw": print("syntax: /xstream raw <command>") else: connect(word[1], quality, server) elif len(word) == 3: connect(word[1], word[2], server) elif len(word) == 4: connect(word[1], word[2], word[3]) else: print("Usage: /xstream (<channel>) (<quality>) (<server>)") return xchat.EAT_ALL
def on_msg(word, word_eol, userdata): sender = word[0][1:] recipient = word[2] message = word_eol[3][1:] if not is_highlight(sender, recipient, message): return xchat.EAT_NONE ctx = xchat.find_context(server=xchat.get_info('server'), channel=hilight_query_name) if not ctx: # Open a query if it isn't there yet xchat.command('query -nofocus %s' % hilight_query_name) ctx = xchat.find_context(server=xchat.get_info('server'), channel=hilight_query_name) if message[0] == message[-1] and message[0] == '\x01': # CTCP. Only honor CTCP action aka /me if message[1:7].lower() != 'action': return xchat.EAT_NONE ctx.emit_print('Channel Action Hilight', '%s/%s' % (sender[:sender.find('!')], recipient), message[8:-1], '') else: ctx.emit_print('Channel Msg Hilight', '%s/%s' % (sender[:sender.find('!')], recipient), message, '') return xchat.EAT_NONE
def o_command(word, word_eol, userdata): if isop(): xchat.command("mode %s -o %s" % (xchat.get_info('channel'), xchat.get_info('nick'))) else: xchat.command("msg ChanServ OP %s %s" % (xchat.get_info('channel'), xchat.get_info('nick'))) return xchat.EAT_ALL
def slap(word, word_eol, userdata): try: xchat.command("ME slaps {0} around a bit with a {1}".format(word[1], ' '.join(word[2:]))) xchat.command("SAPART {0} {1} {2}".format(word[1], xchat.get_info("channel"), "Slapped!")) xchat.command("SAJOIN {0} {1}".format(word[1], xchat.get_info("channel"))) except: print("Syntax is /slap person fish") return xchat.EAT_ALL
def CheckJoin(word,word_eol,userdata): global hosts servChan = xchat.get_info("host")+"/"+xchat.get_info("channel") nick = word[0] user,host = tuple(word[2].split("@")) if servChan not in hosts: hosts[servChan] = {} hosts[servChan][nick] = (user,host) return xchat.EAT_NONE
def CheckJoin(word, word_eol, userdata): global hosts servChan = xchat.get_info("host") + "/" + xchat.get_info("channel") nick = word[0] user, host = tuple(word[2].split("@")) if servChan not in hosts: hosts[servChan] = {} hosts[servChan][nick] = (user, host) return xchat.EAT_NONE
def get_nick(first_word=None, network=None): ''' Get the key id of a nick (if specified) or channel. ''' if first_word: nick = first_word.split('!')[0] if '!' in first_word else first_word else: nick = xchat.get_info('channel') return '{}@{}'.format(nick, network or xchat.get_info('network'))
def __init__(self): # Auto Delete after database size gets bigger than <some size> # self.max_size = (1024 * 1024) * 1024 if os.name != "posix": self.dbconnection = sqlite3.connect(xchat.get_info("xchatdir") + "\\seen.db") else: self.dbconnection = sqlite3.connect(xchat.get_info("xchatdir") + "/seen.db") self.curs = self.dbconnection.cursor() self.curs.execute("CREATE TABLE IF NOT EXISTS seen (nick TEXT UNIQUE, msg TEXT)")
def banned(word, word_eol, userdata): '''Looks like we've been banned from a channel, lets get payback!''' #I was going to add kicking.. Its not really 'pacback' yet.. if xchat.get_info("server") == "opsimathia.datnode.net": print("* \x02[Banned]\x02 Attempting to takeover channel {0}.".format(word[0])) xchat.command("SAJOIN {0} {1}".format(xchat.get_info("nick"), word[0])) xchat.command("SAMODE {0} +q {1}".format(word[0], xchat.get_info("nick"))) else: print("* \x02[Banned]\x02 from channel {0}.".format(word[0]))
def search(word, word_eol, userdata): """Searches whatever messages we have for any passed arguments. If userdata is equal to 'a', usernames and messages will be searched for matches. If userdata is equal to 'u', only usernames will be searched for matches. Finally, if userdata is equal to 'm', only messages will be searched for matches. Found matches are highlighted. The above rules are respected for highlighting matches. """ channel = xchat.get_info("channel") network = xchat.get_info("network") if network not in networks: print("\00307Nothing to search in %s." % network) return if channel not in networks[network]: print("\00307Nothing to search in %s:%s." % (network, channel)) return args = split(word_eol[1]) msgs = [] for msg in networks[network][channel]: # Convert the timestamp to H:M:S format, then get the nickname's color. timestamp = strftime("%H:%M:%S", localtime(msg[0])) ucolor = color(msg[1]) found = False for arg in args: if userdata == 'a' and (arg in msg[1] or arg in msg[2]): found = True user = "******" % (ucolor, replace_arg(msg[1], arg), ucolor) umsg = replace_arg(msg[2], arg) elif userdata == 'u' and arg in msg[1]: found = True user = "******" % (ucolor, replace_arg(msg[1], arg), ucolor) umsg = msg[2] elif userdata == 'm' and arg in msg[2]: found = True user = ucolor umsg = replace_arg(msg[2], arg) if found: # Append result to msgs, which will be used later, and break # so the same match isn't counted multiple times if multiple # arguments are passed. msgs.append("%s\t%s\017: %s" % (timestamp, user, umsg)) break if len(msgs) > 0: # Open a new dialog and print all found results in it. xchat.command("DIALOG Search") dialog = xchat.find_context(network, "Search") for msg in msgs: dialog.prnt(msg) else: print("\00307No results founds in %s:%s." % (network, channel)) return xchat.EAT_ALL
def get_nick(first_word=None, network=None): ''' Get the key id of a nick (if specified) or channel. ''' if first_word: nick = first_word.split( '!')[0] if '!' in first_word else first_word else: nick = xchat.get_info('channel') return '{}@{}'.format(nick, network or xchat.get_info('network'))
def search_bot_current_chan(bot_name): global queue if (type(bot_name) != str): return None serv = xchat.get_info("host"); chan = xchat.get_info("channel"); if serv is None or chan is None: print "Not Connected!" return xchat.EAT_ALL return queue.search(bot_name, chan, serv)
def activity_cb(self, word=None, word_eol=None, data=None): # enable after 2.9.6beta3 # see: # https://github.com/hexchat/hexchat/commit/855c20501baba9e0bcda546b6c07f20dc5648659 # http://forum.xchat.org/viewtopic.php?f=5&t=7558 if xchat.get_context() != xchat.find_context(): channel = xchat.get_info("channel") server = xchat.get_info("server") self.add_activity(server, channel) return xchat.EAT_NONE
def dragon(text, text_eol, userdata): reStart = "Welcome back.*{}".format(xchat.get_info("nick")) reDefeated = "{} rolled the die.*You defeated".format( xchat.get_info("nick")) if re.search(reStart, text[1]) or re.search(reDefeated, text[1]): output = "!roll" else: return if output: xchat.get_context().command("say {}".format(output))
def remove_key(self, word, word_eol, userdata): target = word[1] if len(word) >= 2 else xchat.get_info('channel') server = word[2] if len(word) >= 3 else xchat.get_info('server') try: del self.keymap[target, server] print 'Key removed for {} @ {}.'.format(target, server) except KeyError: print 'No key found for {} @ {}.'.format(target, server) return xchat.EAT_ALL
def screensaver_changed(state): ''' Called when screensaver stops or starts state is either: - True: Screensaver activated - False: Screensaver deactivated ''' if state: if xchat.get_info("nick") == backnick: xchat.command("nick %s" % awaynick) else: if xchat.get_info("nick") == awaynick: xchat.command("nick %s" % backnick)
def setup(): global acceptlist global userlist global m acceptlist = [] userlist = xchat.get_list("users") m.SetInfo(xchat.get_info("server"), xchat.get_info("channel"), xchat.get_prefs("irc_nick1")) for x in userlist: if xchat.nickcmp(x.nick, xchat.get_prefs("irc_nick1")) == 0: acceptlist.append([x, 1]) else: acceptlist.append([x, 0])
def __init__(self): # Auto Delete after database size gets bigger than <some size> # self.max_size = (1024 * 1024) * 1024 if os.name != "posix": self.dbconnection = sqlite3.connect( xchat.get_info("xchatdir") + "\\seen.db") else: self.dbconnection = sqlite3.connect( xchat.get_info("xchatdir") + "/seen.db") self.curs = self.dbconnection.cursor() self.curs.execute( "CREATE TABLE IF NOT EXISTS seen (nick TEXT UNIQUE, msg TEXT)")
def dispatch_message(word, word_eol, event): network, channel = xchat.get_info("network"), xchat.get_info("channel") # Dispatch event to each group registered for this channel if network in registered_channels and channel in registered_channels[network]: for group in registered_channels[network][channel]: # Extract nick and coloring if xchat.get_prefs("text_color_nicks"): (nick_color, nick) = re_nick.search(word[0]).groups("") else: nick_color, nick = "", word[0] args = (word[1:] + padding) group.on_chat_message(network, channel, event, nick, nick_color, args, word, word_eol) return xchat.EAT_NONE
def catch_highlight(word, word_eol, userdata): # Input string ends up being # NICK line of text USERMODE nick = word[0] text = word[1] channel = xchat.get_info('channel') server = xchat.get_info('server') highlighttab = xchat.find_context(channel='@highlights') if not highlighttab: xchat.command('NEWSERVER -noconnect @highlights') highlighttab = xchat.find_context(channel='@highlights') highlighttab.prnt('%s/%s <%s> %s' % (server, channel, nick, text)) return xchat.EAT_NONE
def OrDidI(word,word_eol,userdata): global didJoin nick = word[0] nick = nick[1:nick.find("!")] if nick == xchat.get_info("nick"): chan = fc(word[2]) if chan[0] == ":": chan = chan[1:] servChan = xchat.get_info("server") + "/" + chan if servChan not in didJoin: xchat.command("part " + chan) return xchat.EAT_ALL else: del didJoin[servChan]
def local_google(word, word_eol, userdata): if option["resultsintab"] == True: xchat.command("query " + xchat.get_info("nick")) destination = xchat.find_context(channel=xchat.get_info("nick")) destination.command("settab >>Google<<") else: destination = xchat.get_context() if word[1] == 'query': threading.Thread(target=google_query, args=(word_eol[2], option["locallimit"], destination)).start() if word[1] == 'spell' or word[1] == 'spelling': threading.Thread(target=google_spelling, args=(word_eol[2], destination)).start() return xchat.EAT_ALL
def __init__(self, bot, num): self.bot = str(bot) self.num = int(num) self.channel = xchat.get_info("channel") self.network = xchat.get_info("network") self.context = xchat.get_context() self.file = "" self.retries = 0 self.queue_position = 0 self.queued = False self.transfering = False self.dead = False self.s = "ctcp %s xdcc send #%d" % (str(bot), int(num))
def keypress_cb(word, word_eol, userdata): global undobufs global redobufs bufname = '{}_{}'.format(hexchat.get_info('channel'), hexchat.get_info('network')) key = word[0] mod = word[1] inputtext = hexchat.get_info('inputbox') # Previous strings are stored as deque's in a dict for each channel if not bufname in undobufs: undobuflist = undobufs[bufname] = deque(maxlen=undolevels) else: undobuflist = undobufs[bufname] if not bufname in redobufs: redobuflist = redobufs[bufname] = deque(maxlen=redolevels) else: redobuflist = redobufs[bufname] if (key, mod) == ('122', ctrlmod): # ctrl+z try: # Get last saved string text = undobuflist.pop() if text == inputtext: # First undo may result in same text redobuflist.append(text) text = undobuflist.pop() hexchat.command('settext {}'.format(text)) hexchat.command('setcursor {}'.format(len(text))) redobuflist.append(text) except IndexError: pass # No undos left elif ((key, mod) == ('121', ctrlmod) or # ctrl+y (key, mod) == ('90', shiftctrlmod)): # ctrl+shift+z try: text = redobuflist.pop() if text == inputtext: text = redobuflist.pop() hexchat.command('settext {}'.format(text)) hexchat.command('setcursor {}'.format(len(text))) except IndexError: pass else: # Just throw anything else in here if it has changed if not undobuflist or undobuflist[-1] != inputtext: undobuflist.append(inputtext)
def get_bot_current_chan(bot_name): global queue if (type(bot_name) != str): return None serv = xchat.get_info("host"); chan = xchat.get_info("channel"); if serv is None or chan is None: print "Not Connected!" return xchat.EAT_ALL bot = queue.search(bot_name, chan, serv) if bot is None: bot = t_bot(bot_name, serv, chan) queue.add(bot) return bot
def dispwallop(word, word_eol, userdata): SRV = xchat.get_info("server") srvWin = xchat.find_context(server='%s' % SRV) for i in xchat.get_list("channels"): dispwallop_dbg(xchat, ("Server: %s; Network: %s; Name: %s; Type: %d" % (i.server, i.network, i.channel, i.type))) if i.type == 1 and i.server == xchat.get_info("server"): srvWin = i.context #srvWin = xchat.find_context(i.server,i.channel) dispwallop_dbg(srvWin, "Here's srvWin") dispwallop_dbgEmit(srvWin, "Notice",'%s/Wallops@%s' % (word[0], SRV),'%s' % word[1]) srvWin.emit_print("Notice",'%s/Wallops' % word[0],'%s' % word[1]) srvWin.command("gui color 3") return xchat.EAT_ALL
def flag(word, word_eol, userdata): channel = xchat.get_info('channel') modes = xchat.get_info('modes') if isinstance(modes, basestring): modes = modes.partition(' ')[0] if channel[0] == '#' and ('S' in modes or 'c' in modes): xchat.prnt('ERROR: Detected channel mode S or c') return xchat.EAT_ALL try: flag = country_to_flag(word[1]).split('\n') for line in flag: xchat.command('say ' + line) except LookupError: xchat.prnt('ERROR: No such country code') return xchat.EAT_ALL
def flag(word, word_eol, userdata): channel = xchat.get_info("channel") modes = xchat.get_info("modes") if isinstance(modes, basestring): modes = modes.partition(" ")[0] if channel[0] == "#" and ("S" in modes or "c" in modes): xchat.prnt("ERROR: Detected channel mode S or c") return xchat.EAT_ALL try: flag = country_to_flag(word[1]).split("\n") for line in flag: xchat.command("say " + line) except LookupError: xchat.prnt("ERROR: No such country code") return xchat.EAT_ALL
def channel_msg_processor(word, word_eol, userdata): if (sounds_on == 0): return xchat.EAT_NONE current_channel = xchat.get_info("channel") current_nick = xchat.get_info("nick") # print "Channel message received on %s" % (current_channel) if current_channel in sounds_dic: sound_file = sounds_dic[current_channel] else: sound_file = sounds_dic['other'] play_mysound(sound_file) return xchat.EAT_NONE
def translateOutgoing(word, word_eol, userdata): if len(word) < 2: return xchat.EAT_NONE channel = xchat.get_info("channel") user = word[0].lower() key = channel + " " + user if key in WATCHLIST: dest, src, cnt = WATCHLIST[key] if src != "auto": addTranslationJob(word_eol[1], src, dest, channel, user, ECHO, True) return xchat.EAT_ALL key = key[:-1] if key in WATCHLIST: dest, src, cnt = WATCHLIST[key] if src != "auto": addTranslationJob(word_eol[1], src, dest, channel, user, ECHO, True) return xchat.EAT_ALL return xchat.EAT_NONE
def chan_command(word, word_eol, userdata): channel = xchat.get_info('channel') command = xchat.strip(word[1].split(' ', 1)[0]) if channel.lower() in data.allowed_chans: user, action, arg = get_args(word) if command == "#d": if action in data.commands: if action == data.commands[0]: if arg: send_message(channel, add_device(user, arg)) else: send_message(channel, "Usage: #d add <device>") elif action == data.commands[1]: if arg: send_message(channel, rem_device(user, arg)) else: send_message(channel, "Usage: #d remomve <device_id>") elif action == data.commands[2]: if arg: send_message(channel, list_devices(arg)) else: send_message(channel, "Usage: #d list <user>") elif action == data.commands[3]: if arg: send_message(channel, search_devices(arg)) else: send_message(channel, "Usage: #d search <device>") elif action: arg = action send_message(channel, list_devices(arg))
def nick_check(userdata): if xchat.get_info("nick") != option["mynick"]: xchat.command("release") xchat.command("nick " + option["mynick"]) for chan in option["opin"]: xchat.command("chanserv op " + chan + " " + option["mynick"]) return 1
def addUser(word, word_eol, userdata): global WATCHLIST if len(word) < 2: return xchat.EAT_ALL user = word[1] src = "auto" dest = DEFAULT_LANG if len(word) > 2: src = findLangCode(word[2]) if src is None: xchat.prnt("The specified language is invalid.") return xchat.EAT_ALL pass if len(word) > 3: lang = findLangCode(word[3]) if lang is not None: dest = lang pass key = xchat.get_info("channel") + " " + user.lower() WATCHLIST[key] = (dest, src, 0) xchat.prnt("Now watching user: "******", source: " + src + ", target: " + dest) return xchat.EAT_ALL
def base_message(self, user, message, channel, scope): nick = xchat.get_info('nick') notify = None # Match on one rule for now, later we might support multi matches for multi dests # or what ever. But right now I'm only needing growl and one type of match. matched = self.rules.filter_match(user, channel, message, nick) if matched: if 'callback' in matched: notify = matched['callback'](scope, user, channel, message, nick) if not type(notify) == dict and notify is not None: notify = { "message": notify, 'title': 'Misc', 'notif': 'Notify' } else: #simulated response object... Used if I don't care to callback notify = { 'message': message, 'title': 'Misc', 'notif': 'Notify' } if notify: self.alert(**notify)
def EXChatMPD(word, word_eol, userdata): current_nick = xchat.get_info("nick") if (len(word) <= 1): get_playing_song(current_nick) else: get_playing_song(word[1]) return xchat.EAT_ALL
def scanChannels(word, word_eol, userdata): if xchat.get_info("server") is None: xchat.prnt("Connect before scanning for common denominators") return xchat.EAT_ALL my_users = getUsers() channels = [] for channel in getChannels(): users = list(set(my_users) & set(getUsers(channel.context))) if (len(users)): channels.append({"channel": channel, "users": users}) xchat.prnt("--- Common Denominator Chart") if channels: for channel in sorted(channels, key=lambda c: len(c["users"]), reverse=True): xchat.prnt("") xchat.prnt(channel["channel"].channel + ": " + str(len(channel["users"]))) xchat.prnt(" ".join(sorted(channel["users"]))) else: xchat.prnt("") xchat.prnt("You have no common denominators here!") return xchat.EAT_ALL
def isOperator(): """Return True if you are an operator in the channel of the current context, False if not.""" myNick = xchat.get_info("nick") userlist = xchat.get_list("users") userPrefixes = dict([(user.nick, user.prefix) for user in userlist]) return (userPrefixes[myNick] in OPERATOR_PREFIXES)
def told(text, text_eol, userdata): if len(text) > 1: target = text[1].strip() else: target = xchat.get_info('channel') xsay('{} status:'.format(target)) xsay('☑ TOLD') xsay('☐ NOT TOLD') return xchat.EAT_ALL