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
def do_command(cmd): if is_op(): hexchat.command(cmd) do_op(deop=True) return False return True
def hide_hints(network, channel): global halt hexchat.command("clear") halt = True for msg in networks[network][channel]: hexchat.emit_print(msg['event'], *msg['data'], time=msg['time']) halt = False
def close_cb(word, word_eol, userdata): name = hexchat.get_info('channel') # Ignore ZNC queries and channels if name[0] != '*' and name[0] != '#': recently_cleared.append(name) hexchat.command('znc clearbuffer {}'.format(name))
def converter(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 = "" lower = random.choice([False, True]) for word in hexchat.get_info("inputbox").strip(" ").split(" "): newWord = "" for letter in word: if not lower: letter = letter.upper() else: letter = letter.lower() newWord = newWord + letter lower = not lower output = output + " " + newWord if output else output + newWord hexchat.command("say " + output) hexchat.command("settext ") return hexchat.EAT_ALL return hexchat.EAT_NONE
def key_press(word, word_eol, userdata): global confirm key = int(word[0]) modifier = int(word[1]) if key == 65293 or key == 65421: message = hexchat.get_info('inputbox') if not re.search('[\r\n]', message): return hexchat.EAT_NONE if modifier == 0: if confirm: confirm = False return hexchat.EAT_NONE hexchat.prnt('The input field contains a multiline message. Press \002enter\002 again to send or \002shift+enter\002 to replace newlines with " | ".') confirm = True return hexchat.EAT_ALL elif modifier == 1: message = re.sub('(^\s+|\s+$)', '', message) message = re.sub('\s*[\r\n]+\s*', ' | ', message) hexchat.command('SETTEXT %s' % message) return hexchat.EAT_ALL else: confirm = False return hexchat.EAT_NONE
def slap_cb(word, word_eol, userdata): if len(word) > 1: hexchat.command('me slaps {} in da face with a large trout'.format(word[1])) else: hexchat.command('help slap') return hexchat.EAT_ALL
def np(argv, argv_to_eol, c): session_bus = dbus.SessionBus() spotify_bus = session_bus.get_object("org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2") spotify_properties = dbus.Interface(spotify_bus, "org.freedesktop.DBus.Properties") metadata = spotify_properties.Get("org.mpris.MediaPlayer2.Player", "Metadata") hexchat.command("me [Now playing] " + metadata["xesam:artist"][0] + " - " + metadata["xesam:title"])
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)
def on_np3(word, word_eol, userdata): vlcurl = 'http://[::1]:8080/requests/status.xml' vlcrealm = 'VLC stream' location = 'http://[::1]:8080/' username = '' password = '******' auth = urllib.request.HTTPBasicAuthHandler() auth.add_password(vlcrealm, location, username, password) opener = urllib.request.build_opener(auth) urllib.request.install_opener(opener) status = urllib.request.urlopen(vlcurl) tree = xml.etree.ElementTree.parse(status) root = tree.getroot() for artist in root.findall(".//*[@name='artist']"): artist = artist.text for title in root.findall(".//*[@name='title']"): title = title.text for length in root.findall('length'): t = int(length.text) m = t // 60 s = t - m * 60 minutes = str(m) seconds = str(s) for bitrate in root.findall(".//*[@name='Bitrate']"): bits = re.sub(r' kb/s', 'kb/s', bitrate.text) hexchat.command("say np3("+artist+" - "+title+")("+minutes+"m"+seconds+"s/"+bits+")") return hexchat.EAT_ALL
def now_playing(word, word_eol, userdata): try: # URL for MPC web interface. Check under Options -> Web Interface, listen on port and allow localhost only. url = 'http://127.0.0.1:13579/info.html' # Request the URL r = requests.get(url) # Get the body of the page content = r.text # Convert text to CP1252 encoding since that's what the MPC Web interface reports convert = content.encode('cp1252').decode('utf-8') # Convert the html content into a beautiful soup object soup = BeautifulSoup(convert, "html5lib") # If no web interface then MPC isn't running except: hexchat.prnt('Nothing open in MPC') return # Get the info from the page to parse with regex nowplaying = soup.p.string # Take the text found on the page and run it through regex to grab the info line = re.search('(MPC.*?)\s(.*?)\s•\s(.*?)\s•\s(.*?)\s•\s(.*?(GB|MB))', nowplaying, flags=re.UNICODE) if len(word) > 1 and (word[1] == 'v' or word[1] == 'full'): hexchat.command('SAY Now Playing in {1} : {3} @ {4} [{5}]'.format(line.group(0), line.group(1), line.group(2), line.group(3), line.group(4), line.group(5))) else: hexchat.command('SAY Now Playing in {1} : {3} '.format(line.group(0), line.group(1), line.group(2), line.group(3), line.group(4), line.group(5))) return hexchat.EAT_ALL
def slap_func(word, word_eol, userdata): if len(word) >= 2: for nick in word[1:]: hexchat.command("me slaps \002{}\002 around a bit with a large trout.".format(nick)) else: hexchat.prnt(str_prefix + "Could not slap. " + help) return hexchat.EAT_ALL
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
def slap_cb(word, word_eol, userdata): if len(word) > 1: hexchat.command('me slaps {} around a bit with an unusually large trout'.format(word[1])) else: hexchat.command('help slap') return hexchat.EAT_ALL
def NickClashMsg(word, word_eol, userdata): file = open(currentDirName + passwordFile, 'r') password = file.readline().replace('\n','') file.close() hexchat.command("ns ghost %s %s" % (botName, password)) hexchat.command("nick %s" % botName) return hexchat.EAT_PLUGIN
def bbl_cb(word, word_eol, userdata): if len(word) >= 1 and (word[0].lower().strip(',-_') in away_triggers or word[-1].lower().strip(',-_') in away_triggers): if word[0].strip(',-_') in strip_words: away = word_eol[1] else: away = word_eol[0] hexchat.command( "AWAY %s" % away )
def joinChannels(): actualChanList = hexchat.get_list('channels') chanList = db.listChans() for chan in chanList: if chan not in [x.channel for x in actualChanList]: hexchat.command("join %s" % chan)
def statusCheck(): if not status["declareFailure"]: if hexchat.get_info("server") != None: status["connected"] = True if not status["connected"] and not status["connecting"]: if status["connectAttempt"] >= MAX_CONN_ATTEMPTS: # reset attempts, but don't try again for 10 minutes print(">>> Maximum connection attempts reached (%d), will try again later" % MAX_CONN_ATTEMPTS) status["connectAttempt"] = 0 hexchat.hook_timer(600000, delayedStatusCheck) else: print(">>> Attempting to connect to server") hexchat.command("server %s %s" % (serverName, portNum)) status["connecting"] = True status["connectAttempt"] += 1 elif not status["identified"] and not status["identifying"]: print(">>> Attempting to identify with server") hexchat.command("nick %s" % botName) identifyWithServer() status["identifying"] = True else: print(">>> Attempting to join channels") joinChannels()
def send_message(word, word_eol, userdata): message = word_eol[0] if message.startswith('>') and not (preferences.ignore_emoticons and len(message) > 1 and message[1] != ' ' and not message[1].isalpha()): message = hexstuff.color_text(message, hexstuff.COLOR_GREEN) hexchat.command('PRIVMSG %s :%s' % (hexchat.get_info('channel'), message)) hexchat.emit_print('Your Message', hexchat.get_info('nick'), message) return hexchat.EAT_HEXCHAT
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
def mpc_hc(word, word_eol, userdata): data = urllib2.urlopen(MPC_HC_URL).read() mpc_hc_np = MPC_HC_REGEXP.findall(data.decode("utf-8"))[0].replace("«", "«") mpc_hc_np = mpc_hc_np.replace("»", "»") mpc_hc_np = mpc_hc_np.replace("•", "•") hexchat.command("say %s" % mpc_hc_np) return hexchat.EAT_ALL
def magic_cb(word, word_eol, userdata): if len(word) > 1: nick = word[1] hexchat.command('me shakes the Magic 8 Ball. It answers: ' + choice(magics).format(nick)) else: hexchat.command('help magic8') return hexchat.EAT_ALL
def Converter(word, word_eol, userdata): if word < 3: hexchat.prnt(help) elif word[2] == 'announce': if word[1] == 'c': x = float(word[3]) y = ((x-32)*.5556) hexchat.command(u'say \x0312{0}\u00B0F\x0f to \x0312Celsius\x0f: \x0304{1}'.encode('utf-8').format(word[3], y)) elif word[1] == 'f': x = float(word[3]) y = ((x/.5556)+32) hexchat.command(u'say \x0312{0}\u00B0C\x0f to \x0312Fahrenheit\x0f: \x0304{1}'.encode('utf-8').format(word[3], y)) else: return 'Error' elif word[2] != 'announce': if word[1] == 'c': x = float(word[2]) y = ((x - 32)*.5556) hexchat.prnt(u'\x0312{0}\u00B0F\x0f to \x0312Celsius\x0f: \x0304{1}'.encode('utf-8').format(word[2], y)) elif word[1] == 'f': x = float(word[2]) y = ((x/.5556)+32) hexchat.prnt(u'\x0312{0}\u00B0C\x0f to \x0312Fahrenheit\x0f: \x0304{1}'.encode('utf-8').format(word[2], y)) else: return 'Error' else: return 'Error' return hexchat.EAT_ALL
def goto_blackjack_bet(self): self.state = 'blackjackbet' self.function.betsremaining = [] for a in self.function.playernames: self.function.betsremaining.append(a) hexchat.command('say '+str(self.function.betsremaining)) hexchat.command('say Betting phase. Please input your bets in integer numbers.')
def modifyKickData(word,word_eol,userdata): if word[1][-1:] == '\xA0': # we need to modify this! kicknick = word[1][:-1].replace(' ','\xA0') hexchat.emit_print('Kick',word[0],kicknick+'@'+OMNOMIDENTSTR,word[2],word_eol[3]) if hexchat.nickcmp(kicknick,hexchat.get_info('nick'))!=0: hexchat.command('RECV :'+kicknick+'!()\xA0'+kicknick+'@'+OMNOMJOINIGNORE+' PART '+word[2]) return hexchat.EAT_ALL
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
def inputHook(self, word, word_eol, userdata): result = hexchat.EAT_NONE if not self.sent: self.sent = True if len(word) > 0: if word[0].startswith("\\"): hexchat.command("say " + word_eol[0][1:]) result = hexchat.EAT_ALL elif word[0].startswith(self.cmdPrefix): result = hexchat.EAT_ALL cmd = word[0][1:] cmdResult = self.doCommandStr(cmd, word[1:], None) if cmdResult == 1: print("command '%s' not found" % (cmd)) else: outLineResult = self.outLine("say " + word_eol[0]) if outLineResult[0]: hexchat.command(outLineResult[1]) result = hexchat.EAT_ALL self.sent = False return result
def amule_cb(word, word_eol, userdata): """Read aMule's onlinesig file and shows up/down speeds and total downloaded in the active channel. Arguments: word -- array of strings sent by HexChat/X-Chat to every hook (ignored) word_eol -- array of strings sent by HexChat/X-Chat to every hook (ignored) userdata -- optional variable that can be sent to a hook (ignored) """ if path.exists(_AMULESIG): lines = open(_AMULESIG, "r").readlines() if lines[0] == "0": helper.gprint("aMule isn't connected") else: down_speed = (lines[6])[0:-1] up_speed = (lines[7])[0:-1] total_down = helper.units(int(lines[11]), 1024) version = lines[13][0:-1] hexchat.command("".join(["say ( aMule ", version, " )", " Download: ", down_speed, "KB/s -", " Upload: ", up_speed, "KB/s -" " Downloaded: ", total_down])) else: helper.gprint([_AMULESIG, " file does not exist, check whether you", " have 'Online signature' enabled in your aMule", " settings"]) return hexchat.EAT_ALL
def slap_cb(word, word_eol, userdata): if len(word) > 1: nick = word[1] hexchat.command('me ' + choice(slaps).format(nick)) else: hexchat.command('help slap') return hexchat.EAT_ALL
def highlight_cb(word, word_eol, userdata): if not regex.search(word_eol[1]): return hexchat.EAT_NONE # The command "GUI COLOR" changes the channel tab color to: # 0) visited # 1) new data # 2) new message # 3) new highlight hexchat.command("GUI COLOR 3") # Print the highlighted text hexchat.emit_print("Channel Msg Hilight", *word) return hexchat.EAT_ALL
def em_cb(words, word_eol, userdata): if len(word_eol) > 1: msg = word_eol[1] emojized = emojize(msg) if COMMAND_EM_SIMULATE in ['say', 'em']: cmd = COMMAND_EM_SIMULATE else: cmd = 'say' hexchat.command('{0} {1}'.format(cmd, emojized)) return hexchat.EAT_HEXCHAT hexchat.command('help em') return hexchat.EAT_ALL
def send_message(word, word_eol, userdata): if (word[0] == "65289"): return autocomplete() global emoji_autocompletion, last_msg emoji_autocompletion = [] last_msg = [] if not (word[0] == "65293"): return hexchat.EAT_NONE msg = hexchat.get_info('inputbox') if msg is None: return hexchat.EAT_NONE replaced = emoji.emojize(msg, use_aliases=True) if replaced != msg: hexchat.command("settext %s" % replaced)
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
def doStuff(word, eol, data): try: suffix = word[1] hexchat.command("say ~" + suffix) hexchat.command("nick " + oldnick + "|" + suffix) except IndexError: hexchat.command("say ~") hexchat.command("nick " + oldnick)
def comandoRolador(word, word_eol, userdata): if len(word) < 5: print( "Por favor utilize /rola QTD LADOS MOD NOME_PERSONAGEM sendo que o QTD, LADOS e NOME_PERSONAGEM não podem ser vazios!!!" ) else: qtd = int(word[1]) #QTD lados = int(word[2]) #LADOS mod = int(word[3]) #MOD nome = word[4] #PERSONAGEM frase = rolarDado(nome, qtd, lados, mod) canal = hexchat.get_info("channel") comando = "msg " + canal + " " + frase hexchat.command(comando) return hexchat.EAT_ALL
def command_flip(command, command_eol, params): chars = { "a": "ɐ", "b": "q", "c": "ɔ", "d": "p", "e": "ǝ", "f": "ɟ", "g": "ƃ", "h": "ɥ", "i": "ı", "j": "ɾ", "k": "ʞ", "l": "l", "m": "ɯ", "n": "u", "o": "o", "p": "d", "q": "b", "r": "ɹ", "s": "s", "t": "ʇ", "u": "n", "v": "ʌ", "w": "ʍ", "x": "x", "y": "ʎ", "z": "z", "!": "¡", "A": "∀", "B": "q", "C": "Ɔ", "D": "◖", "E": "Ǝ", "F": "Ⅎ", "G": "⅁", "H": "H", "I": "I", "J": "ſ", "K": "⋊", "L": "˥", "M": "W", "N": "N", "O": "O", "P": "Ԁ", "Q": "Ό", "R": "ᴚ", "S": "s", "T": "⊥", "U": "∩", "V": "Λ", "W": "ʍ", "X": "X", "Y": "⅄", "Z": "Z", "?": "¿", "1": "Ɩ", "2": "ᄅ", "3": "Ɛ", "4": "ㄣ", "5": "ϛ", "6": "9", "7": "ㄥ", "8": "8", "9": "6", "0": "0", "_": "‾", "/": "\\", "\\": "/", "`": ",", ".": "˙", "(": ")", ")": "(", "[": "]", "]": "[", "<": ">", ">": "<", "{": "}", "}": "{", "\"": ",,", "&": "⅋" } try: newstring = "" for character in command_eol[1]: try: character = character.replace(character, chars[character]) except KeyError: pass newstring += character newstring = ''.join(reversed(newstring)) hexchat.command(f"say {newstring}") except IndexError: print(f"\002** Syntax:\002 /{command[0]} [text]") return hexchat.EAT_HEXCHAT
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
def spacko(word, word_eol, userdata): random.seed(time.time()) l = [ 'Ist der Hund kugelrund, frisst er Spacko, wie ein Schlund!', 'Frisst Ihr Hund Spacko-Futter, wird er selbst zu Spacko-Futter!', 'Spacko-Futter für den Hund, da gehts dem ganzen Hund gesund!', 'Kauft Spacko-Futter für euren Spacko-Hund!', 'Spacko, Spacko, Spacko-Hund, und schnell in meinem Mund!' ] spacko_string = l[random.randrange(len(l))] hexchat.command('say »{}«'.format(spacko_string)) return hexchat.EAT_HEXCHAT
def blackjackbet(self, word, word_eol, userdata): try: word[1] = int(word[1]) except: return hexchat.EAT_ALL if word[0].lower() in self.function.betsremaining and word[1] > 0: a = self.function.addbet(word[0].lower(), int(word[1])) if a == False: hexchat.command('say You do not have enough money!') return hexchat.EAT_ALL elif a == True: del self.function.betsremaining[ self.function.betsremaining.index(word[0].lower())] if len(self.function.betsremaining) == 0: self.start_blackjack() return hexchat.EAT_ALL
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))
def process_backslashed_line(self, word_eol): backslashed_line = word_eol[0] hexchat.command("say " + backslashed_line[1:]) outLineResult = self.outLine("say " + backslashed_line[1:]) # implement noout in debugsects by testing for None if outLineResult[1] is None: # means we're testing: # noout is in debugSects, so mute user output # and don't do anything else pass result = hexchat.EAT_ALL return result
def donate_cookie(word, word_eol, userdata): global cookie_count, cookie_donators # If someone gives you a cookie, increment the cookie_count variable by 1. if 'gives ' + hexchat.get_info('nick') + ' a cookie' in word[1]: cookie_count += 1 if word[0] not in cookie_donators: cookie_donators[word[0]] = 1 else: cookie_donators[word[0]] += 1 # Respond to the donator. hexchat.command( 'me Hugs {}. "Thank you for your generous donation! ^^"'.format( word[0])) return hexchat.EAT_NONE
def send_message(word, word_eol, userdata): global enabled if not enabled: return hexchat.EAT_NONE message = word_eol[0] channel = hexchat.get_info('channel') output = subprocess.Popen("{} \"{}\"".format(filepath, message), stdout=subprocess.PIPE, shell=True).communicate()[0].decode('UTF-8') for line in output.split('\n'): hexchat.command("say {} {}".format(channel, line)) return hexchat.EAT_ALL
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
def print_nowplaying(track, echo=False): try: title = track['name'] artist = track['artist']['#text'] album = track['album']['#text'] title = title.encode('utf-8') artist = artist.encode('utf-8') album = album.encode('utf-8') except KeyError: print('Lastfm: Song info not found') return if echo: cmd = 'me is now playing 2{} by 4{} on 8{}.'.format(title, artist, album) hexchat.command(cmd)
def slap(word, word_eol, userdata): innick = word[1] inchan = hexchat.get_info("channel") inserver = hexchat.get_info("server") innetwork = hexchat.get_info("network") slaps = [ "pokes {nick} with a tazer", "hurls the holy hand grenade of antioch at {nick}", "clears {nick}'s head with the help of a baseball bat", "applies a small amount of acid to {nick}", "begins to plot {nick}'s demise", "starts planning an accident for {nick}", "stores all of {nick}'s data on floppies next to an extremely " "strong magnet", "Throws a CRT monitor at {nick}", "sends all of {nick}'s usernames and passwords to {chan}", "drops a piano on {nick}", "drops a complete hardcopy log of {chan} on {nick}", "drops a 100EB NAS on {nick}", "drops {chan} on {nick}", "drops {nick} on {nick}", "shreds {nick}'s ram while their system is running", "slaps {nick} around with some soviet propaganda", "slaps {nick} with a sheet of {chan} propaganda", "drops the network on {nick}", "drops {network} on {nick}", "drops a server on {nick}", "drops {server} on {nick}", "causes a netsplit and blames {nick}", "splits out {server} and blames {nick}", "drops a planet on {nick}", "drops LV-426 on {nick}", "throws {nick} into a supermassive black hole", "throws {nick} into Sagittarius A*", "hits {nick} with a small moon", "covers {nick} in chlorine trifluoride, steps back and watches " "them burn", "drops {nick} into Mount Doom", "makes all {nick}'s messages be sent as WALLOPs", "makes all of {nick}'s messages be sent via WALLCHAN", ] hexchat.command("me {}".format( random.choice(slaps).format(nick=innick, chan=inchan, server=inserver, network=innetwork))) return hexchat.EAT_ALL
def hostignore(word, word_eol, userdata): userlist = hexchat.get_list('users') action = userdata if len(word) <= 1: nea() return hexchat.EAT_ALLs user = getHost(userlist, word[1]) host = user.host.split('@')[1] if user.nick.lower() == word[1].lower(): hexchat.command('%s *!*@%s' % (action, host)) else: unf() return hexchat.EAT_ALL
def identify(self): """ Issue the command to identify to the NickServ bot. The default auto-identify behavior of HexChat sends this incorrectly, which is the reason I am writing this script """ if self.nick: assert self.nick == hexchat.get_info( "nick") # Ensure we are authenticating for the right account commandString = "msg NickServ IDENTIFY {0}".format( self.password) # Leading forward-slash not necessary hexchat.command(commandString) hexchat.prnt("Sent command to identify.") return hexchat.EAT_NONE # Returning this value ensures the event is not consumed and other plugins can still use it
def action_cb(word, word_eol, userdata): nickname = word[0] action = word[1] channel = hexchat.get_info('channel') network = hexchat.get_info('network') if hexchat.get_context() == hexchat.find_context(): return hexchat.EAT_NONE else: header = '"Highlighted action from: {} ({}/{})"'.format(nickname, channel, network) mainjunk = '* {} {}'.format(nickname, action) fullthing = 'tray -b {} {}'.format(header, mainjunk) hexchat.command(fullthing) return hexchat.EAT_NONE
def pyglatin_cb(word, word_eol, userdata): if len(word) < 2: hexchat.prnt("-\00322PygLatin\00399-\tUsage: /pyg <message>") else: word.remove(word[0]) for w in word: first = w[0] spliced = w[1:] if first.lower() in vowels: word[word.index(w)] = w + pyg else: word[word.index(w)] = spliced + first + pyg new_msg = " ".join(word) hexchat.command("SAY {0}".format(new_msg)) return hexchat.EAT_ALL
def np(word, word_eol, userdata): metastr = get_mpd_string() if metastr is None: metastr = get_mplayer_string() if metastr is None: metastr = get_youtube_string() if metastr is None: hexchat.prnt('Es wird zur zeit nichts abgespielt.') return hexchat.EAT_HEXCHAT outputstr = '♫ {} ♫'.format(metastr) hexchat.command('me is listening to: {}'.format(outputstr)) return hexchat.EAT_HEXCHAT
def doRemove(self, cmdString, argList, kwargs): result = 0 # no error if dex("rm", self.debugSects) != -1: debugRm = True else: debugRm = False channel = None nick = None reason = None if len(argList) == 0: self.debugPrint("remove usage:") self.debugPrint("remove <nick>") self.debugPrint( "remove <nick> \"reason\" # must quote reason in 2-arg form") self.debugPrint( "remove <channel> <nick> <reason> # need not quote reason in 3-arg form" ) else: # not zero args if len(argList) >= 3: reason = " ".join(argList[2:]) nick = argList[1] channel = argList[0] else: if len(argList) == 2: reason = argList[1] nick = argList[0] channel = hexchat.get_info("channel") if len(argList) == 1: nick = argList[0] reason = nick channel = hexchat.get_info("channel") removeCommand = "remove " + channel + " " + nick if reason is not None: removeCommand += " :" + reason if debugRm: self.debugPrint("debugRm: " + removeCommand) else: hexchat.command(removeCommand) return result
def msg_cb(word, word_eol, event_name, attrs): global edited if edited or is_today(attrs.time): return format = hexchat.get_prefs('stamp_text_format') hexchat.command('set -quiet stamp_text_format {}'.format('%m-%d ' + format)) edited = True hexchat.emit_print(event_name, word[0], word[1], time=attrs.time) edited = False hexchat.command('set -quiet stamp_text_format {}'.format(format)) return hexchat.EAT_ALL
def cmd_wb_cb(word, word_eol, userdata): argc = len(word) string = "" if argc == 1: string = wb_cmd() elif argc == 2: string = wb_cmd(word[1]) elif argc == 3: string = wb_cmd(word[1], word[2]) else: string = wb_cmd(word[1], word[2], word_eol[3]) if (string is not None): hexchat.command("MSG %s %s" % (hexchat.get_info("channel"), string)) return hexchat.EAT_ALL
def oncmd(word, word_eol, userdata): if len(word) >= 2: cmd = commands.get(word[1].lower()) if cmd[0]: signature = inspect.signature(cmd[0]) if len(signature.parameters) > 0: if len(word) == 3: cmd[0](word[2]) elif len(word) > 3: cmd[0](" ".join(word[2:])) else: print("not enough args") else: cmd[0]() else: hexchat.command("HELP SNOTE") return hexchat.EAT_HEXCHAT
def get_mask(nick): invalid_chars = ('*', '?', '!', '@', '$') if any(char in nick for char in invalid_chars): return nick # It's already a mask. for user in hexchat.get_list('users'): if hexchat.nickcmp(user.nick, nick) == 0: if user.account: return '$a:{}'.format(user.account) elif user.host: host = user.host.split('@')[1] return '*!*@{}'.format(host) else: hexchat.command('whois {}'.format(nick)) print( 'BH: User info not found, enable irc_who_join or try again.' ) return None
def np_cb(word, word_eol, userdata): try: itunes = win32com.client.Dispatch('iTunes.Application') except pywintypes.com_error: print( "itunes: Failed to communicate with itunes. Note that this requires admin access and you should have had a UAC prompt." ) return hexchat.EAT_ALL # TODO: Settings try: track = itunes.CurrentTrack hexchat.command('me is now playing {} by {} on {}'.format( track.Name, track.Artist, track.Album)) except AttributeError: print('No song was found playing.') return hexchat.EAT_ALL
def print_cb(word, word_eol, event, attr): global edited # Ignore our own events, bouncer playback, empty messages if edited or attr.time or not len(word) > 1: return if any(_word in word[1] for _word in hlwords): msg = word[1] for _word in hlwords: msg = msg.replace(_word, '\00320' + _word + '\00399').strip() # Color red edited = True hexchat.emit_print(event, word[0], msg) edited = False hexchat.command('gui color 3') return hexchat.EAT_ALL
def masskick(word, word_eol, userdata): reason = "{}".format(hexchat.get_info("nick")) if len(word) < 2: print("I need an argument") else: reason = "No reason specified" i = 0 for words in word: if words.startswith(":"): reason = " ".join(word[i:]) reason = reason[1:] word = word[1:i] break i += 1 for nicks in word: hexchat.command("QUOTE KICK {} {} :{}".format( hexchat.get_info("channel"), nicks, reason)) return hexchat.EAT_ALL
def whisper_cb(word, word_eol, userdata): hexchat.command('PRIVMSG %s :. /w %s' % (hexchat.get_info('channel'), word_eol[1].encode('utf-8'))) whisper = hexchat.get_info('nick') + ' >> ' + word[1] + ': ' + word_eol[2] hexchat.prnt('\002\00326' + whisper.encode('utf-8') + '\002\00326') return hexchat.EAT_ALL