# WhereAmI.py # An X-Chat Python Script by Maulsel # What it does: When someone types "where is" and your nick (or any of your highlight words), # it will say some stuff about where you are, and your away message, etc. # Tested on: X-Chat Aqua 0.16.0 # You may modify this code as long as you keep the copyright info. # Copyright: Script is Public Domain. Originally Created by Maulsel. import xchat, time __module_name__ = "WhereAmI" __module_version__ = "0.93" __module_description__ = "Outputs a \"Where Am I?\" message when someone says \"Where is\" + your nick in a channel." xchat.prnt("Loading WhereAmI script...") # let's define some strings for output first soutput_whereis = "Where is " soutput_isaway = "I am away: " soutput_question = "?" soutput_lastmsg = "Last message: " soutput_inchan = " in channel " soutput_to = " to " soutput_onserv = " on " soutput_at = " at " soutput_wentaway = "I went away" soutput_ago = "ago." soutput_looking = "I am looking at " soutput_check1 = "where is" soutput_check10 = "where" soutput_check11 = "is" soutput_check12 = "are" soutput_check13 = "you" soutput_check2 = "where's" soutput_dateformat = "%b. %d %Y %H:%M:%S %Z" #start info? info = [0, 0, 0, 0, 0] info[3] = "0" def whereis_cb(word, word_eol, userdata): respondwhereis = 0 phrase = word[1].lower() if soutput_check10 in phrase: if soutput_check11 in phrase: respondwhereis = 1 if soutput_check12 in phrase: if soutput_check13 in phrase: respondwhereis = 1 if soutput_check2 in phrase: respondwhereis = 1 if respondwhereis == 1: awaymsg = str(xchat.get_info("away")) if awaymsg == "None": isaway = 0 else: isaway = 1 channeltooutput = xchat.get_info("channel") contextout = xchat.find_context(channel=channeltooutput) contextlook = xchat.find_context() # gonna get the name now :O nick = xchat.get_info("nick") output = "" output += soutput_whereis + nick + soutput_question if isaway == 1: output += " " + soutput_isaway + '"' + awaymsg + '".' else: output += " " + soutput_looking + contextlook.get_info("channel") + soutput_onserv + contextlook.get_info("server") + "." if userdata[3] == 1: if userdata[0][0] == "#": output += " " + soutput_lastmsg + '"' + userdata[2] + '"' + soutput_inchan + userdata[0] + soutput_onserv + userdata[1] + soutput_at + str(userdata[4]) + "." else: output += " " + soutput_lastmsg + '"' + userdata[2] + '"' + soutput_to + userdata[0] + soutput_onserv + userdata[1] + soutput_at + str(userdata[4]) + "." contextout.command("MSG " + channeltooutput + " " + output) def storeinfo_cb(word, word_eol, userdata): mamama = xchat.get_info("nick") if soutput_whereis + mamama + '?' not in word[1]: chlist = xchat.get_list("channels") curchan = xchat.get_info("channel") for i in chlist: if i.channel == curchan: info[0] = i.channel info[1] = i.server info[2] = word[1] info[3] = 1 info[4] = time.strftime(soutput_dateformat) def unload_cb(userdata): xchat.prnt("Unloaded WhereAmI.") xchat.hook_print("Your Message", storeinfo_cb) xchat.hook_print("Channel Msg Hilight", whereis_cb, info) xchat.hook_unload(unload_cb) xchat.prnt("Loaded WhereAmI script.")