<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, May 15, 2006, 12:17 PM -->
<!-- MuClient version 3.70 -->

<!-- Plugin "Aardwolf_FriendXListLUA" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Aardwolf_FriendXListLUA"
   author="Onoitsu2"
   id="8fb8b0371a8c5d74242a5459"
   language="Lua"
   purpose="This adds friendX features"
   save_state="y"
   date_written="2006-05-15 12:10:03"
   requires="3.65"
   version="1.0"
   >
<description trim="n">
<![CDATA[
Commands are as follows: (without the <> of course)

friendx <add> <name>            - adds a friend of name to the friendx list
friendx <rem> <name>            - removes a friend of name from the friendx list
friendx <list>                  - lists everyone on your friendx list
friendx <note> <board>          - composes a note to everyone on your friendsx list,
                                  on the specified board (if none specified default = personal)
friendx <tell> <message>        - sends a tell with message to everyone on your friendsx list
friendx <finger>                - does a finger of everyone on your friendsx list
friendx <whois>                 - does a whois of everyone on your friendsx list
friendx <where>                 - does a where on everyone on your firendsx list

friendx <help>                  - shows this list of commands

]]>
</description>

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Aliases  -->

<aliases>
  <alias
   match="^friendx\s(add|rem)\s(.*?)$"
   enabled="y"
   group="friendx"
   regexp="y"
   ignore_case="y"
   script="friendxaddrem"
   sequence="100"
  >
  </alias>
  <alias
   match="^friendx(\s)note((\s)(.*?)|)$"
   enabled="y"
   group="friendx"
   regexp="y"
   ignore_case="y"
   script="friendxnote"
   sequence="100"
  >
  </alias>
  <alias
   match="^friendx(\s)tell\s(.*?)$"
   enabled="y"
   group="friendx"
   regexp="y"
   ignore_case="y"
   script="friendxtell"
   sequence="100"
  >
  </alias>
  <alias
   match="^friendx(\s)finger$"
   enabled="y"
   group="friendx"
   regexp="y"
   ignore_case="y"
   script="friendxfinger"
   sequence="100"
  >
  </alias>
  <alias
   match="^friendx(\s)where$"
   enabled="y"
   group="friendx"
   regexp="y"
   ignore_case="y"
   script="friendxwhere"
   sequence="100"
  >
  </alias>
  <alias
   match="^friendx(\s)whois$"
   enabled="y"
   group="friendx"
   regexp="y"
   ignore_case="y"
   script="friendxwhois"
   sequence="100"
  >
  </alias>
  <alias
   match="^friendx(\s)list$"
   enabled="y"
   group="friendx"
   regexp="y"
   ignore_case="y"
   script="friendxlist"
   sequence="100"
  >
  </alias>
</aliases>

<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   regexp="y"
   group="friendx"
   ignore_case="y"
   match="^friendx help$"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[

flist = GetVariable("friendxlist")
if flist == nil then
flist = ""
end
-- startup loading

function OnPluginSaveState()
SetVariable("friendxlist", flist)
end

function friendxaddrem(sName, sLine, wildcards)
local list = flist
cmd = string.lower(wildcards[1])
who = string.lower(wildcards[2])
if cmd == "add" then
if list == "" then
	list = who
	ColourNote("white", "blue", "Added Friend: " .. string.upper(who))
else
	for friend in string.gfind(list, "[^||]+") do
	if friend == who then
		ColourNote("white", "red", "User " .. string.upper(who) ..  " already in your FriendX List")
		return
	end
	end
	list = list .. "||" .. who
	ColourNote("white", "blue", "Added Friend: " .. string.upper(who))
end
flist = list
SaveState()
elseif cmd == "rem" then
fwanted = string.lower(wildcards[2])
ffound = 0
fnewlist = ""
count = 0
for friend in string.gfind(list, "[^||]+") do
	if friend == fwanted then
		ffound = 1
	else
		if count > 0 then
			fnewlist = fnewlist .. "||"
		end
	count = count + 1
	fnewlist = fnewlist .. friend
	end
end
if ffound == 0 then
  ColourNote("white", "red", "User " .. string.upper(fwanted) .. " not in your FriendX List")
else
  flist = fnewlist
  SaveState()
  ColourNote("white", "green",  "User " .. string.upper(fwanted) .. " removed from your FriendX List")
end
end
end -- friendxaddrem

function friendxtell(sName, sLine, wildcards)
	local list = flist
	count = 0
	Note("1 = " .. wildcards[1] .. " 2 = " .. wildcards[2])
	msg = wildcards[2]
	if list == "" or list == nil then
	ColourNote("white", "red", "No friends on your FriendX List")
	return
	end
	print ("")
	for friend in string.gfind(list, "[^||]+") do
		Send("tell " .. friend .. " " .. msg)
	count = count + 1
	end
	if count > 0 then
		ColourNote("white", "blue", count .. " friend(s) sent a tell")
	else
		ColourNote("white", "red", "No friends to tell")
	end
	ColourNote("white", "black", "")
end -- friendxtell

function friendxfinger(sName, sLine, wildcards)
	local list = flist
	count = 0
	if list == "" or list == nil then
	ColourNote("white", "red", "No friends on your FriendX List")
	return
	end
	print ("")
	for friend in string.gfind(list, "[^||]+") do
		Send("finger " .. friend)
	count = count + 1
	end
	if count > 0 then
		ColourNote("white", "blue", count .. " friend(s) fingered")
	else
		ColourNote("white", "red", "No friends to finger")
	end
	ColourNote("white", "black", "")
end -- friendxfinger

function friendxwhere(sName, sLine, wildcards)
	local list = flist
	count = 0
	if list == "" or list == nil then
	ColourNote("white", "red", "No friends on your FriendX List")
	return
	end
	print ("")
	for friend in string.gfind(list, "[^||]+") do
		Send("where " .. friend)
	count = count + 1
	end
	if count > 0 then
		ColourNote("white", "blue", count .. " friend(s) where'd")
	else
		ColourNote("white", "red", "No friends to where")
	end
	ColourNote("white", "black", "")
end -- friendxwhere

function friendxwhois(sName, sLine, wildcards)
	local list = flist
	count = 0
	if list == "" or list == nil then
	ColourNote("white", "red", "No friends on your FriendX List")
	return
	end
	print ("")
	for friend in string.gfind(list, "[^||]+") do
		Send("whois " .. friend)
	count = count + 1
	end
	if count > 0 then
		ColourNote("white", "blue", count .. " friend(s) whois'd")
	else
		ColourNote("white", "red", "No friends to whois")
	end
	ColourNote("white", "black", "")
end -- friendxwhois

function friendxnote(sName, sLine, wildcards)
	local list = flist
	local tempsend = " "
	count = 0
	board = wildcards[2]
	Note(wildcards[2])
	if board == "" or board == " " or board == nil then
	board = "personal"
	end
	if list == "" or list == nil then
	ColourNote("white", "red", "No friends on your FriendX List")
	return
	end
	print ("")
	for friend in string.gfind(list, "[^||]+") do
			if count > 0 then
			tempsend = tempsend .. " "
			end
	count = count + 1
	tempsend = tempsend .. friend
	end
	if count > 0 then
		ColourNote("white", "blue", count .. " friend(s) added to note")
		Send("board " .. board)
		Send("note write" .. tempsend)
		--Send(tempsend)
	else
		ColourNote("white", "red", "No friends to add to note")
	end
	ColourNote("white", "black", "")
end -- friendxnote

function friendxlist(sName, sLine, wildcards)
count = 0
	local list = flist
	if list == "" or list == nil then
	ColourNote("white", "red", "No friends on your FriendX List")
	return
	end
	print ("")
	for friend in string.gfind(list, "[^||]+") do
		if count == 0 then
			ColourNote("white", "blue", "-- Your FriendX List --")
		end
		ColourNote("white", "blue", friend)
		count = count + 1
	end
	if count > 0 then
		ColourNote("white", "blue", count .. " friends on FriendX list(s)")
	else
		ColourNote("white", "red", "No friends on your FriendX list")
	end
	ColourNote("white", "black", "")
end -- friendxlist

function OnPluginInstall()
OnHelp()
end

function OnHelp(sName, sLine, wildcards)
  Note(world.GetPluginInfo(world.GetPluginID(), 3))
end
]]>
</script> 

</muclient>
