def steiner(text, text_eol, userdata): ignore = ['swim', 'seventyNexus', 'SeventyTwo', 'Noxialis', 'ChanServ', 'cocaine', 'Ultimation_', 'roofletrain', 'Serpentine', 'hachimitsu-boy', 'whatapath', 'YourImaginaryFriend', 'RocketLauncher', 'Onee-chan', 'Fijou', 'DarkAceLaptop', 'GayServ', 'zingas', 'rpk', 'qb', 'mkillebrew', 'whoapath', 'guymann', 'Doomfag', 'maws', 'cunnelatio', 'DenSaakalte', 'martian', 'irc', 'cyberdynesystems', 'net', 'somberlain', 'PhilKenSebben', 'kyokugen', 'Erotica', 'mechanicalTurk', 'ed', 'anon__', 'E-Pain', 'thenoize', 'skew', 'StoneColdSteveAustin', 'frussif', 'Ultimation', 'charles', 'i7MUSHROOM', 'slamm', 'h**o', 'Hypnotized', 'Dr_Venture', 'AoC', 'Porygon', 'axujen', 'Jax', 'Special-G', 'peopleschampion', 'LtSerge', 'Dwarf', 'pinetreegator', 'Cap', '[^_^]', 'swam', 'Clear', 'takoyaki', 'keret', 'MeanPocket', 'keref', 'hachi', 'vortmax', 'War', 'Hachi-chan', 'JediDachshund', 'BillGates', 'BTDT', 'kk', 'guy9000', 'Erzengel', 'Revived', 'BradPitt', 'Colink', 'ekOz', 'Jynweythek'] steiner = "" nick = xchat.strip(text[0]).translate(str.maketrans("", "", "+%@&~")) if nick in ignore or "ScottSteiner" not in xchat.get_info("nick"): return if text[1] == "nothing gayer": steiner = "than {}".format(nick) elif re.search("nothin(?:g(?:'s|)|)gayer", text[1]): steiner = "{} is a f****t".format(nick) elif re.search("nothin(?:g(?:'s|)|) finer than", text[1]) or text[1] == "no one kinder than": steiner = "Scott Steiner" elif re.search("nothin(?:g(?:'s|)|) finer", text[1]) or text[1] == "no one kinder": steiner = "than Scott Steiner" elif text[1] == "nothing is finer": steiner = "than {} being a dumbfuck inbred retard who still can't into a simple script".format(nick) elif text[1] == "big poppa pump": steiner = "IS YOUR HOOKUP. HOLLER IF YA HEAR ME" if steiner: print("{0}<{1}{0}> {2}".format("\x0307", text[0],text[1])) xchat.get_context().command("say {}".format(steiner)) global steinerhook, steinertimer xchat.unhook(steinerhook) steinertimer = xchat.hook_timer(60000, steinertoggle) steinerhook = None return xchat.EAT_XCHAT
def reset_activity_cb(self, word=None, word_eol=None, data=None): channel = xchat.get_context().get_info("channel") server = xchat.get_context().get_info("server") if server and channel: key = server + ":" + channel self.activity[key] = 0 return xchat.EAT_NONE
def wrap(self, datatype, data, nick): #print "wrap:", type, str(data)[:80], nick SIZE = 384 # Max size allowed for one part assert PREFIXES.has_key(datatype) if datatype == "pub": encoded = self.str2baseX(data.exportKey()) elif datatype == "key": encoded = self.str2baseX(data) elif datatype == "sig": encoded = self.dec2baseX(data) elif datatype == "enc": encoded = self.str2baseX(data) elif datatype == "mul": encoded = data if len(encoded) > SIZE: #Sends recursively parts in this order: N, N-1, ..., 1 MsgWrapper.wrap("mul", encoded[SIZE:], nick) envio = PREFIXES[datatype] + encoded[:SIZE] xchat.get_context().command("raw privmsg " + nick + " " + envio) else: envio = PREFIXES[datatype] + encoded xchat.get_context().command("raw privmsg " + nick + " " + envio)
def private_cb(word, word_eol, userdata): global focus_context, notify_context if not same_context(focus_context, xchat.get_context()): tips.set_tip(icon, ("[%s]: %s"%(word[0], word[1]))[0:79]) tips.enable() icon.show_all() notify_context = xchat.get_context() return xchat.EAT_NONE
def private_cb(word, word_eol, userdata): global focus_context, notify_context if not same_context(focus_context, xchat.get_context()): tips.set_tip(icon, ("[%s]: %s" % (word[0], word[1]))[0:79]) tips.enable() icon.show_all() notify_context = xchat.get_context() return xchat.EAT_NONE
def fl_hook(word, word_eol, userdata): if xchat.get_info("win_status") == "active": return xchat.EAT_NONE set_flashlight(1) global fl_contexts context = xchat.get_context() if context not in fl_contexts: fl_contexts.append(xchat.get_context()) 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 enchode_cb(word, word_eol, userdata): input = word_eol[1][:150] s = choder.enchode(input, 2, 340) buffer["input"] = s.splitlines() for dongs in buffer["input"]: xchat.get_context().command('say ' + dongs) del buffer["input"] xchat.emit_print( "Channel Message", '\0034\002\037' + xchat.get_info('nick') + '\0034\002\037', input, "") return xchat.EAT_XCHAT
def on_message(word, word_eol, userdata): user = word[0] message = word[1].strip().lower() for trigger, response in responses: if message.find(trigger) != -1: if response[0] == '*': xchat.get_context().command('me ' + response[1:]) else: xchat.get_context().command('say ' + response) return xchat.EAT_XCHAT return xchat.EAT_XCHAT
def on_address(word, word_eol, userdata): user = word[0] message = word[1].strip() pattern = r'^' + username + r"[^A-Za-z0-9]*<(.+)><(.+)>$" m = re.match(pattern, message) if m: responses.append([m.group(1), m.group(2)]) xchat.get_context().command('say ' + '^_^') return xchat.EAT_ALL else: on_message(word, word_eol, userdata) xchat.get_context().command('say ' + 'nya?') return xchat.EAT_ALL
def on_nowplaying(word, word_eol, userdata): bus = dbus.SessionBus() if bus.name_has_owner('org.mpris.MediaPlayer2.spotify'): spotify = bus.get_object('org.mpris.MediaPlayer2.spotify','/org/mpris/MediaPlayer2') # Get current channel and get latest track from Spotify context = xchat.get_context() channel = context.get_info("channel") metadatas = dbus.Interface(spotify,'org.freedesktop.DBus.Properties') trackinfo = metadatas.Get('org.mpris.MediaPlayer2.Player','Metadata') # Get track information from DBus dictionary album = unicode(trackinfo.get("xesam:album")).encode('utf-8') title = unicode(trackinfo.get("xesam:title")).encode('utf-8') trackNumber = str(unicode(trackinfo.get("xesam:trackNumber")).encode('utf-8')) discNumber = str(unicode(trackinfo.get("xesam:discNumber")).encode('utf-8')) trackid = str(unicode(trackinfo.get("xesam:trackid")).encode('utf-8')) length = unicode(trackinfo.get("xesam:length")).encode('utf-8') artUrl = unicode(trackinfo.get("xesam:artUrl")).encode('utf-8') url = unicode(trackinfo.get("xesam:url")).encode('utf-8') # The artist list is provided as an array. Combine all artists to a single string. artist = str(unicode(", ".join(trackinfo.get("xesam:artist"))).encode('utf-8')).strip() npmsg = "Now playing on 02Spotify: %s - %s [%s] (%s)" % (artist, title, album, url) xchat.command("msg %s %s" % (channel, npmsg)) return xchat.EAT_ALL else: return xchat.EAT_ALL
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 print_help(): context = xchat.get_context() printStr = [] printStr.append("/weather Syntax:") printStr.append("/weather or /weather short") context.prnt(str("\n").join(printStr))
def focus_cb(word, word_eol, userdata): global focus_context, notify_context focus_context = xchat.get_context() if same_context (notify_context, focus_context): icon.hide() tips.disable() return xchat.EAT_NONE
def weapon_context(word, word_eol, userdata): nicks = [] for nick in word: nicks.append(nick.strip(',')) _isop = isop() ctx = dict(context=xchat.get_context(), times=0, nicks=nicks, wasop=_isop) return ctx
def sharedchannels_cb(word, word_eol, userdata): mynickname = xchat.get_context().get_info("nick") excluded_users = [mynickname, 'ChanServ'] # a list of users to ignore, including your nickname(s) if len(word) < 2 or word[1][0] != '#': usage(); return xchat.EAT_XCHAT chan1 = word[1] cc = xchat.find_context(channel=chan1) if not cc: print "Oops - you don't seem to be in channel", chan1 return xchat.EAT_XCHAT chan1server = cc.get_info('server') userlist = {} for chan in xchat.get_list('channels'): if chan.server == chan1server and chan.type == chantype['channel']: for user in chan.context.get_list('users'): if user.nick not in excluded_users: userlist.setdefault(chan.channel, []).append(user.nick) print "###############################################################################" # 79 print "# " + ("The users in %s share the following channels with you (%s)" % (chan1, mynickname)).center(79-4) + " #" print "###############################################################################" # 79 for chan in sorted(userlist.keys()): if chan != chan1: usersincommon = sorted(set(userlist[chan1]) & set(userlist[chan])) if usersincommon: print "%15s:\t%s" % (chan, ', '.join(usersincommon)) print "###############################################################################" # 79 return xchat.EAT_XCHAT
def on_text(word, word_eol, userdata): if option["service"] != True: return counter = 0 destination = xchat.get_context() network = destination.get_info('network').lower() channel = destination.get_info('channel').lower() triggernick = word[0].lower() if option["service"] == True and option["relayonly"] == True and triggernick not in option["relaynicks"]: return for badword in option["badwords"]: if re.search(badword, word[1], re.I): counter += 1 for relaypair in option["relaypairs"]: if relaypair[0] == network and relaypair[1] == channel: destination = xchat.find_context(server=relaypair[2], channel=relaypair[3]) try: if counter == 0: for key in option["replacements"].keys(): word_eol[1] = string.replace(word_eol[1],key,option["replacements"][key]) destination.command("say " + "<"+triggernick+"> " + word_eol[1]) elif option["relaydefaultmsg"] == True: destination.command("say " + "<"+triggernick+"> " + option["defaultmsg"]) except AttributeError: print color["red"], "It appears you have not joined the relay destination channel", relaypair[3], "on", relaypair[2]
def on_pvt(word, word_eol, userdata): destination = xchat.get_context() triggernick = word[0] trigger = re.split(' ', word[1].lower()) if trigger[0] == '!weather' and option["service"] == True: get_weather(trigger[1], destination)
def ReadySend(word,word_eol,userdata): global dTimers if GetOpt(0) != "none" and GetOpt(2): #xchat.prnt("%s joined channel..prepping for message." % word[0]) dTimers[word[0]] = xchat.hook_timer(GetOpt(1), SendMessage, [word[0],xchat.get_context()]) #endif return xchat.EAT_NONE
def checkPrint(word, word_eol, userdata): " if someone says '.giphy', respond like 'found http://blah.gif " del(word_eol, userdata) # shut up, pylint if ' ' in word[1]: cmd, params = word[1].split(' ', 1) else: cmd, params = word[1], None context = xchat.get_context() chan = context.get_info('channel') if cmd == '!giphy': if not params: return xchat.NONE if chan in LASTUSED: now = time.time() if LASTUSED[chan] + TIMEOUT >= now: context.command('msg {} "!giphy" on cooldown'.format(word[0])) else: found = fetchAPIresults(params) if found: context.command('me found \x1f{}\x0f'.format(found)) else: context.command('me couldn\'t search Giphy') print '*** error searching Giphy' LASTUSED[chan] = now return xchat.EAT_PLUGIN
def __init__(self, title, masters, players, hardcore): self.title = title self.masters = masters self.hardcore = hardcore self.players = players session.add(self) characters_list = [] for each_player in players: new_character = Character() new_character.name = unicode(each_player.nick) new_character.games = [self] session.add(new_character) characters_list.append(new_character) self.characters = characters_list session.commit() players_string = "" for each_player in self.players: if players.index(each_player) < len(players)-1: players_string += each_player.nick + ", " else: players_string += each_player.nick context = xchat.get_context() say(context, '[' +self.title + '] ' + '게임이 시작되었습니다. (마스터: ' + self.masters[0].nick + ', ' + '플레이어: ' + players_string + ')')
def pvt_request(word, word_eol, userdata): destination = xchat.get_context() triggernick = word[0] trigger = re.split(' ',string.lower(word[1])) if option["service"] == True: if trigger[0] in versions and option["service"] == True: #get_text(trigger[:3], destination) threading.Thread(target=get_text, args=(trigger[:3], destination)).start() if trigger[0] == '!search' and trigger[1] in versions: #get_search(trigger[1], trigger[2:], triggernick) threading.Thread(target=get_search, args=(trigger[1], trigger[2:], triggernick)).start() if trigger[0] == '!searchbybook' and trigger[1] in versions: #get_searchbybook(trigger[1], trigger[2], trigger[3:], triggernick) threading.Thread(target=get_searchbybook, args=(trigger[1], trigger[2], trigger[3:], triggernick)).start() if trigger[0] == '!help': #play_file(option["helpfile"], triggernick) threading.Thread(target=play_file, args=(option["helpfile"], triggernick)).start() if trigger[0] == '!rules': #play_file(option["rulesfile"], triggernick) threading.Thread(target=play_file, args=(option["rulesfile"], triggernick)).start() if trigger[0] == '!versions': #play_file(option["versionfile"], triggernick) threading.Thread(target=play_file, args=(option["versionfile"], triggernick)).start() if trigger[0] == '!list' and trigger[1] in versions: #get_list(trigger[1], triggernick) threading.Thread(target=get_list, args=(trigger[1], triggernick)).start()
def on_text(word, word_eol, userdata): if option["service"] != True: return counter = 0 destination = xchat.get_context() network = destination.get_info('network').lower() channel = destination.get_info('channel').lower() triggernick = word[0].lower() if option["service"] == True and option[ "relayonly"] == True and triggernick not in option["relaynicks"]: return for badword in option["badwords"]: if re.search(badword, word[1], re.I): counter += 1 for relaypair in option["relaypairs"]: if relaypair[0] == network and relaypair[1] == channel: destination = xchat.find_context(server=relaypair[2], channel=relaypair[3]) try: if counter == 0: for key in option["replacements"].keys(): word_eol[1] = string.replace( word_eol[1], key, option["replacements"][key]) destination.command("say " + "<" + triggernick + "> " + word_eol[1]) elif option["relaydefaultmsg"] == True: destination.command("say " + "<" + triggernick + "> " + option["defaultmsg"]) except AttributeError: print color[ "red"], "It appears you have not joined the relay destination channel", relaypair[ 3], "on", relaypair[2]
def focus_cb(word, word_eol, userdata): global focus_context, notify_context focus_context = xchat.get_context() if same_context(notify_context, focus_context): icon.hide() tips.disable() return xchat.EAT_NONE
def shout(word, word_eol, userdata): global bold_char, audtool_prog current = xchat.get_context() if audacious_check(): #playing? playing = commands.getstatusoutput(audtool_prog + " playback-playing") if (playing[0] == 0): song = commands.getoutput(audtool_prog + " current-song") artist = commands.getoutput(audtool_prog + " current-song-tuple-data artist") total = commands.getoutput(audtool_prog + " current-song-length") output = commands.getoutput(audtool_prog + " current-song-output-length") final = bold_char + "Now Playing: " + bold_char + song + (" - ") + artist + " (" + output + "/" + total + ")" #make sure it's not in a server window if ((current.get_info("channel") != current.get_info("server")) and (current.get_info("channel") != current.get_info("network"))): #Say it. xchat.command("msg " + current.get_info("channel") + " " + final) else: #Print it current.prnt(final) else: current.prnt("Check that Audacious is playing!") else: current.prnt("Check that you have Audacious installed and audtool_prog set properly!") #accept the command no matter what happens, to prevent unknown command messages return xchat.EAT_XCHAT
def checkPrint(word, word_eol, userdata): " if someone says '.yt', respond like 'found http://youtu.be/asdf " del (word_eol, userdata) # shut up, pylint # "PRIVMSG Jane :that smells bad" # word[0] = 'Jane' word[1] = 'that smells bad' # word_eol[0] = 'Jane that smells bad' word_eol[1] = 'that smells bad' if ' ' in word[1]: cmd, params = word[1].split(' ', 1) else: cmd, params = word[1], None context = xchat.get_context() chan = context.get_info('channel') if cmd == '!yt': if not params: return xchat.NONE if chan in LASTUSED: now = time.time() if LASTUSED[chan] + TIMEOUT >= now: context.command('msg {} "!yt" on cooldown'.format(word[0])) else: found = fetchYTresults(params)[0] if found['id']: context.command( 'me found \x02{}\x0f \x1fhttp://youtu.be/{}\x0f'. format(found['title'], found['id'])) else: context.command('me couldn\'t search YouTube') print '*** error searching YouTube: {}'.format( found['title']) LASTUSED[chan] = now return xchat.EAT_PLUGIN
def sharedchannels_cb(word, word_eol, userdata): mynickname = xchat.get_context().get_info("nick") excluded_users = [ mynickname, 'ChanServ' ] # a list of users to ignore, including your nickname(s) if len(word) < 2 or word[1][0] != '#': usage() return xchat.EAT_XCHAT chan1 = word[1] cc = xchat.find_context(channel=chan1) if not cc: print "Oops - you don't seem to be in channel", chan1 return xchat.EAT_XCHAT chan1server = cc.get_info('server') userlist = {} for chan in xchat.get_list('channels'): if chan.server == chan1server and chan.type == chantype['channel']: for user in chan.context.get_list('users'): if user.nick not in excluded_users: userlist.setdefault(chan.channel, []).append(user.nick) print "###############################################################################" # 79 print "# " + ( "The users in %s share the following channels with you (%s)" % (chan1, mynickname)).center(79 - 4) + " #" print "###############################################################################" # 79 for chan in sorted(userlist.keys()): if chan != chan1: usersincommon = sorted(set(userlist[chan1]) & set(userlist[chan])) if usersincommon: print "%15s:\t%s" % (chan, ', '.join(usersincommon)) print "###############################################################################" # 79 return xchat.EAT_XCHAT
def doAllOp(): if not amIOperator(): return xchat.EAT_NONE context = xchat.get_context() context.command("WHO " + context.get_info("channel")) for user in context.get_list("users"): doSingleOp(user, context)
def hwmon(word, word_eol, userdata): lm_sensors_info, gpu_temp = sysinfo_hwmon() output = [] if lm_sensors_info is None and gpu_temp is None: xchat.prnt('No monitoring sensors detected') return xchat.EAT_ALL if gpu_temp is not None: output.append(u'gpu:: temp0: %d\xb0C' % gpu_temp) if lm_sensors_info is not None: for device_name in lm_sensors_info: temps = lm_sensors_info[device_name]['temps'] temp_output = [] i = 0 if len(temps): for temp in temps: add = ('temp%d: %s' % (i, temp)).decode('utf-8') temp_output.append(add) i += 1 output.append(device_name + ':: ' + ', '.join(temp_output)) output = '; '.join(output) if output: dest = xchat.get_context() output = 'say %s' % wrap('sensor', output) dest.command(output) else: xchat.prnt('No monitoring sensors detected') return xchat.EAT_ALL
def ether(word, word_eol, userdata): # TODO Add iPhone hotspot (find ipheth) def get_ethernet_devices(): devices = pci_find_by_class(PCI_CLASS_NETWORK_ETHERNET) devices += pci_find_by_class(PCI_CLASS_NETWORK_ETHERNET_WIFI) usb_devices = usb_find_by_class(USB_CLASS_NETWORK) usb_devices += usb_find_by_class(USB_CLASS_NETWORK_GENERIC) usb_devices += usb_find_by_class(USB_CLASS_BLUETOOTH) names = [] for device_id, vendor_id in devices: names.append(pci_find_fullname(device_id, vendor_id)) for device_id, vendor_id in usb_devices: names.append(usb_find_fullname(device_id, vendor_id)) return names names = get_ethernet_devices() output = ', '.join(names) if output: dest = xchat.get_context() dest.command('say %s' % wrap('ether', output)) else: xchat.prnt('No ethernet devices found') return xchat.EAT_ALL
def checkPrint(word, word_eol, userdata): " if someone says '.yt', respond like 'found http://youtu.be/asdf " del(word_eol, userdata) # shut up, pylint # "PRIVMSG Jane :that smells bad" # word[0] = 'Jane' word[1] = 'that smells bad' # word_eol[0] = 'Jane that smells bad' word_eol[1] = 'that smells bad' if ' ' in word[1]: cmd, params = word[1].split(' ', 1) else: cmd, params = word[1], None context = xchat.get_context() chan = context.get_info('channel') if cmd == '!yt': if not params: return xchat.NONE if chan in LASTUSED: now = time.time() if LASTUSED[chan] + TIMEOUT >= now: context.command('msg {} "!yt" on cooldown'.format(word[0])) else: found = fetchYTresults(params)[0] if found['id']: context.command('me found \x02{}\x0f \x1fhttp://youtu.be/{}\x0f'.format(found['title'], found['id'])) else: context.command('me couldn\'t search YouTube') print '*** error searching YouTube: {}'.format(found['title']) LASTUSED[chan] = now return xchat.EAT_PLUGIN
def checkPrint(word, word_eol, userdata): " if someone says '.giphy', respond like 'found http://blah.gif " del (word_eol, userdata) # shut up, pylint if ' ' in word[1]: cmd, params = word[1].split(' ', 1) else: cmd, params = word[1], None context = xchat.get_context() chan = context.get_info('channel') if cmd == '!giphy': if not params: return xchat.NONE if chan in LASTUSED: now = time.time() if LASTUSED[chan] + TIMEOUT >= now: context.command('msg {} "!giphy" on cooldown'.format(word[0])) else: found = fetchAPIresults(params) if found: context.command('me found \x1f{}\x0f'.format(found)) else: context.command('me couldn\'t search Giphy') print '*** error searching Giphy' LASTUSED[chan] = now return xchat.EAT_PLUGIN
def on_join(word, word_eol, userdata): triggernick, triggerchannel, triggerhost = word #we could also do triggernick = word[0] #we could also do triggernick = word[1] you get the picture destination = xchat.get_context() destination.command("say Hello " + triggernick + " and welcome to " + triggerchannel)
def UnVoiceChannel(word,word_eol,userdata): global okChannels context = xchat.get_context() cn = context.get_info("channel") del okChannels[cn] xchat.prnt("No longer automatically voicing newcomers in "+cn) return xchat.EAT_ALL
def checkPrint(word, word_eol, userdata): " listen to everything said, sometimes blurt out YouTube wisdom " del(word_eol, userdata) # shut up, pylint # "PRIVMSG Jane :that smells bad" # word[0] = 'Jane' word[1] = 'that smells bad' # word_eol[0] = 'Jane that smells bad' word_eol[1] = 'that smells bad' context = xchat.get_context() chan = context.get_info('channel') if chan not in LASTUSED: return None now = time.time() if LASTUSED[chan] + TIMEOUT >= now: # on cooldown return None if random() > CHANCE: # rolled dice, not now return None LASTUSED[chan] = now wisdom = fetchYTcomment(word[1]) if wisdom: # context.command('say {}'.format(wisdom)) print '{} \x0315"{}"\x0f'.format(YOUTUBELOGO, wisdom) else: print '{} \x0315(nothing found?)\x0f'.format(YOUTUBELOGO) pass return xchat.EAT_NONE
def parseChannelMessage(word,word_eol,userdata): ''' parses a message that starts with cmdc (command character) to see if it is a command for this bot or not. If it is then formulate a suitable response to the command. if it isn't then ignore it. I removed the threading from the bot because I run it on a netbook with limited memory and the threads can cause some memory problems the way I implemented them. ''' xcContext=xchat.get_context() sender,message=(word[0],join(" ",split(word[1]))) firstchar=message[0] if firstchar==cmdc: cmd=split(message[1:]," ") firstpart=lower(cmd[0]) if firstpart=="versions": ss="" for k in versionName: ss=ss+bold+k+bold+"("+versionName[k]+") " say(ss,xcContext) return if firstpart=="help": say("To display a passage type "+bold+";rsv John 3:16"+bold +" all bible book names are abbreviated to their first 3" +" letters, for example 1Kings is 1ki, John is joh, and so forth." +" There are exceptions: Judges is "+bold+"jdg,"+bold +" Judith is "+bold+"jdt"+bold+", and Philemon is " +bold+"phm"+bold,xcContext) say("Searching is done by putting a 's' in front of the" +" version name like this "+bold+";skjv God so loved"+bold +" that will find all the verses in the KJV containing" +" 'God so loved'",xcContext) say("To display versions type "+bold+";versions"+bold,xcContext) return if firstpart[0]=="s": version=upper(firstpart[1:]) if version not in versionName: return phrase=lower(join(" ",cmd[1:])) searchVersion(version,phrase,xcContext) else: if len(cmd)<3: if len(cmd)==2: if upper(cmd[0]) in ["CCC","CCT"]: version=book=upper(cmd[0]) ref="1_"+removePunctuation(cmd[1]) displayPassage(version,book,ref,xcContext) elif len(cmd)==3: version=upper(cmd[0]) if version not in versionName: return book=upper(cmd[1]) if book in ["JUDGES","JUDG"]: book="JDG" elif book in ["JUDITH", "JUDI"]: book="JDT" elif book in ["PHILEMON","PHL"]: book="PHM" elif book in ["RUTH","RUT"]: book="RTH" bref=book[:3] ref=cmd[2] displayPassage(version,bref,ref,xcContext)
def getUsers(context=None): if context is None: context = xchat.get_context() users = context.get_list("users") blacklist = [xchat.get_info("nick"), "ChanServ", "__main__", "__class__"] return [u.nick for u in users if u.nick not in blacklist]
def ghostcb(word, word_eol, userdata): c = xchat.get_context() nick = word[3] #use this instead of preferred nick, I guess. pw = c.get_info("nickserv") u = {"context": c, "nick": nick} u["hook"] = xchat.hook_server("NOTICE", noticecb, userdata=u) xchat.command("msg nickserv ghost {} {}".format(nick, pw)) return xchat.EAT_NONE
def xsys(word, word_eol, userdata): dest = xchat.get_context() dest.command('me is using %s v%s (https://github.com/Tatsh/%s)' % ( __module_name__, __module_version__, __module_name__.split(' ')[0].replace('-', '').lower()) ) return xchat.EAT_ALL
def pvtRequest(word, word_eol, userdata): destination = xchat.get_context() triggernick = word[0] trigger = re.split(' ', string.lower(word[1])) if option["service"] == True: if fileplay.has_key(trigger[0]): playFile(fileplay[trigger[0]], triggernick)
def getChannels(context=None): if context is None: context = xchat.get_context() channels = context.get_list("channels") blacklist = [context.get_info("channel"), 1, 3] return [c for c in channels if c.channel not in blacklist and c.type not in blacklist]
def on_pvt(word, word_eol, userdata): destination = xchat.get_context() triggernick = word[0] trigger = re.split(' ', string.lower(word[1])) if trigger[0] == '!calc' and option["service"] == 'on': calculate(string.join(trigger[1:]), destination) return xchat.EAT_NONE
def ResetChannel(word,word_eol,userdata): global hostsThatJoined context = xchat.get_context() del hostsThatJoined hostsThatJoined = {} cn = context.get_info("channel") xchat.prnt("Everyone is now a newcomer in "+cn) return xchat.EAT_ALL
def steiner(text, text_eol, userdata): ignore = [ 'swim', 'seventyNexus', 'SeventyTwo', 'Noxialis', 'ChanServ', 'cocaine', 'Ultimation_', 'roofletrain', 'Serpentine', 'hachimitsu-boy', 'whatapath', 'YourImaginaryFriend', 'RocketLauncher', 'Onee-chan', 'Fijou', 'DarkAceLaptop', 'GayServ', 'zingas', 'rpk', 'qb', 'mkillebrew', 'whoapath', 'guymann', 'Doomfag', 'maws', 'cunnelatio', 'DenSaakalte', 'martian', 'irc', 'cyberdynesystems', 'net', 'somberlain', 'PhilKenSebben', 'kyokugen', 'Erotica', 'mechanicalTurk', 'ed', 'anon__', 'E-Pain', 'thenoize', 'skew', 'StoneColdSteveAustin', 'frussif', 'Ultimation', 'charles', 'i7MUSHROOM', 'slamm', 'h**o', 'Hypnotized', 'Dr_Venture', 'AoC', 'Porygon', 'axujen', 'Jax', 'Special-G', 'peopleschampion', 'LtSerge', 'Dwarf', 'pinetreegator', 'Cap', '[^_^]', 'swam', 'Clear', 'takoyaki', 'keret', 'MeanPocket', 'keref', 'hachi', 'vortmax', 'War', 'Hachi-chan', 'JediDachshund', 'BillGates', 'BTDT', 'kk', 'guy9000', 'Erzengel', 'Revived', 'BradPitt', 'Colink', 'ekOz', 'Jynweythek' ] steiner = "" nick = xchat.strip(text[0]).translate(str.maketrans("", "", "+%@&~")) if nick in ignore or "ScottSteiner" not in xchat.get_info("nick"): return if text[1] == "nothing gayer": steiner = "than {}".format(nick) elif re.search("nothin(?:g(?:'s|)|)gayer", text[1]): steiner = "{} is a f****t".format(nick) elif re.search("nothin(?:g(?:'s|)|) finer than", text[1]) or text[1] == "no one kinder than": steiner = "Scott Steiner" elif re.search("nothin(?:g(?:'s|)|) finer", text[1]) or text[1] == "no one kinder": steiner = "than Scott Steiner" elif text[1] == "nothing is finer": steiner = "than {} being a dumbfuck inbred retard who still can't into a simple script".format( nick) elif text[1] == "big poppa pump": steiner = "IS YOUR HOOKUP. HOLLER IF YA HEAR ME" if steiner: print("{0}<{1}{0}> {2}".format("\x0307", text[0], text[1])) xchat.get_context().command("say {}".format(steiner)) global steinerhook, steinertimer xchat.unhook(steinerhook) steinertimer = xchat.hook_timer(60000, steinertoggle) steinerhook = None return xchat.EAT_XCHAT
def on_pvt(word, word_eol, userdata): destination = xchat.get_context() triggernick = word[0].lower() trigger = re.split(' ',word[1].lower()) if trigger[0] == '!google' and option["service"] == True: threading.Thread(target=google_query, args=(string.join(trigger[1:]), option["privatelimit"], destination)).start() if trigger[0] == '!spell' or trigger[0] == '!spelling' and option["service"] == True: threading.Thread(target=google_spelling, args=(string.join(trigger[1:]), destination)).start()
def identifycb(word, word_eol, userdata): c = xchat.get_context() match = NICKPATTERN.match(word[0]) matchtxt = "This nickname is registered and protected." if not match or xchat.nickcmp(match.group(1), 'NickServ') != 0: return xchat.EAT_NONE if matchtxt in word_eol[0]: c.command("msg nickserv identify " + c.get_info('nickserv')) return xchat.EAT_NONE
def addJob(word, word_eol, userdata): channel = xchat.get_info('channel') key = channel + " " + word[0].lower() if(AUTOUSER.has_key(key)): dest, src = AUTOUSER[key] ThreadController.addJob((xchat.get_context(), word[0], src, dest, word[1])) return xchat.EAT_NONE
def handler(word, word_eol, userdata): channel = xchat.get_info('channel') command, username = get_args(word) if channel.lower() in channels.allowed and command == "#userinfo": context = xchat.get_context() pool = ThreadPool(processes=1) pool.apply_async(get_user_info, (username, pool, context), callback=send_message) return
def onText(word, word_eol, userdata): destination = xchat.get_context() triggerchannel = xchat.get_info("channel") triggernick = word[0] trigger = re.split(' ', string.lower(word[1])) if option["service"] == True and triggerchannel not in option["notin"]: if fileplay.has_key(trigger[0]): playFile(fileplay[trigger[0]], triggernick)
def flood_start(word, word_eol, userdata): global flood_message flood_message = word_eol[2] global myflooder global flood_context flood_context = flood_context + [xchat.get_context()] print("Starting the flooder...") if len(flood_context) == 1: myflooder = xchat.hook_timer(int(float(word[1]) * 1000), flooding) return xchat.EAT_ALL
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