-----------------------
Friend LisT 2.0
-----------------------


With this plug you will can add a lot of friends and check if they are online.
Bot only will show online players.
This plug dont use the internal FL of bot, it have his Own list ^^

Commands: ( Access 20 )

.FriendLisT
.AddFriend <Username>
.QuitFriend <Username>


Example:

[17:23:07] <1987OrC> .friendlist
[17:23:08] <JuJUjo >> Working << Checking: 49 AccS>
[17:235] <JuJUjo> 1987OrC is using Warcraft III in a private channel.
[17:239] <JuJUjo> You are JuJUjo, using Warcraft III in a private channel.
[17:23:42] <JuJUjo> Pcpcd is using Warcraft III in a private channel.
[17:23:45] <JuJUjo> W3Dinkois using Warcraft III in a private channel.
.
.
.



[17:21:27] <1987OrC> .addfriend zen
[17:21:29] <JuJUjo >> [ zen ] Added To Ext. Friend LisT << TOTAL: 8>
[17:21:42] <1987OrC> .quitfriend zen
[17:21:43] <JuJUjo >>> DoNe <<< LisT UpdateD | Total Friends: 7>

Code:
'ou
'1.0
'&Online Users
'By DrOiD V2.0

Set FLFSO = CreateObject("Scripting.FileSystemObject")
Const ou_access  = 20
Const ou_command = "friendlist"
dim AccStr
dim  TotalFriends
Public ou_active, ou_msg, ou_dsp, ou_user
dim LastMessage

Sub ou_event_Load()
	'AccStr = "x-FreeLoOSe-x"
	
	If FLFSO.FileExists(BotPath() & "plugins\friendlist.txt") Then
		Addchat vbYellow, "FriendLisT.txt found!"
	Else
		Set file1 = FLFSO.OpenTextFile(BotPath() & "plugins\friendlist.txt", 1, True)
	        addchat vbRED, "friendlist.txt not found......DrOiD Txt Maker will create it! ^_^"
	End If


end sub

Sub ou_Event_ServerInfo(Message)
    If Not ou_active Then Exit Sub
    'If Match(LCase(Message), "*: * using *", True) Then
	If Match(LCase(Message), "* using *", True) Then
'        ou_msg = ou_msg & " " & Split(Message)(1)
        ou_msg = ou_msg & " " & Message & " | "				
		if LastMessage <> message then addq  Message
		LastMessage = message
    End If
    If Match(LCase(Message), "battle.net time:*", True) Then
        ou_active = False
        If ou_msg = "" Then
            dsp ou_dsp, "There are no users online.", ou_user, vbCyan
        Else
            'dsp ou_dsp, "Online users:" & Left(ou_msg, Len(ou_msg) - 1), ou_user, vbCyan
	     dsp ou_dsp, mid(Left(ou_msg, Len(ou_msg) - 1),2), ou_user, vbCyan
        End If
        ou_msg = ""
        Exit Sub
    End If
End Sub

Sub ou_Event_WhisperFromUser(Username, Flags, Message)
    GetDBEntry Username, myAccess, myFlags
    If LCase(Message) = BotVars.Trigger & ou_command And myAccess >= ou_access Then
        Call ou_Execute(3)
        ou_user = Username
    End If
End Sub

Sub ou_Event_UserTalk(Username, Flags, Message, Ping)
    GetDBEntry Username, myAccess, myFlags
    if myAccess < ou_access then exit sub
	If LCase(Message) = BotVars.Trigger & ou_command And myAccess >= ou_access Then 
		call LeerFriends("no")	
		addq "/emote >> Working << Checking: " & TotalFriends & " AccS"
		call LeerFriends("si")	
		Call ou_Execute(1)		
	end if		
	if left(LCase(Message),11) = BotVars.Trigger & "addfriend " then	
		AccFriend = mid(Message,12)
		addchat vbred,AccFriend
		call addfriend(AccFriend)	
	end if
	if left(LCase(Message),12) = BotVars.Trigger & "quitfriend " then	
		AccFriend = mid(Message,13)		
		call Removefriend(AccFriend)	
	end if
	
	
End Sub

Sub ou_Event_PressedEnter(Text)
    If LCase(Text) = "//" & LCase(ou_command) Then
        VetoThisMessage
        Call ou_Execute(1)
    ElseIf LCase(Text) = "/" & LCase(ou_command) Then
        VetoThisMessage
        Call ou_Execute(4)
    End If
End Sub

Sub ou_Execute(display)
    
    'If ou_active Then Exit Sub
    ou_active = True
    ou_dsp = display
    addchat vbgreen ,AccStr
	AddQ "/whois " & AccStr

End Sub

Sub LeerFriends(a)	  
	  nombrefichero	 = "friendlist.txt"
	  filepath = BotPath() & "plugins\" & nombrefichero	 
	  addchat vbred , filepath
	  Set fso = CreateObject("Scripting.FileSystemObject")
  	  Set file = fso.OpenTextFile(filepath, 1, False)
	  TotalFriends = 0
 	  Do While Not file.AtEndOfStream 
	      lineT = file.readline
	      if lineT <> "" then 
		     TotalFriends = TotalFriends +1
		     AccStr = lineT			 
			 if a = "si" then Call ou_Execute(1)			 
		  end if
      Loop	
end sub

sub AddFriend(User)	
	
	if IsFriend(User) = "si" then
	   addq "/emote >>> [ " & User & " ] iS in Friend List <<<"
	   Exit Sub
	end if
	
	nombrefichero	 = "friendlist.txt"
    filepath = BotPath() & "plugins\" & nombrefichero
	Set objFS = CreateObject("Scripting.FileSystemObject")
	Set objTS = objFS.OpenTextFile(filepath, 8)
	ObjTS.WriteLine vbNewLine & user
	call LeerFriends("no")
	
	addq "/emote >> [ " & user & " ] Added To Ext. Friend LisT << TOTAL: "  & TotalFriends
	
end sub

Function IsFriend(TxtAcc)

	  IsFriend = "no"
	  nombrefichero	 = "friendlist.txt" 
      filepath = BotPath() & "plugins\" & nombrefichero 
	  Set fso = CreateObject("Scripting.FileSystemObject")
  	  Set file = fso.OpenTextFile(filepath, 1, False)
 	  Do While Not file.AtEndOfStream                    	      
	          line = file.ReadLine
              if lcase(line) = lcase(txtacc) then IsFriend = "si"	      
      Loop

end function

Sub Removefriend(username)


filename = "friendlist.txt"
if Isfriend(username) = "no" then
	   addq "/emote >>> [ " & username & " ] iS NoT in Friend List <<<"
	   Exit Sub
end if       



'Const FOR_READING = 1
'Const FOR_WRITING = 2

strCheckForString = UCase(username)


Nombrefichero = filename

filepath = BotPath() & "plugins\" & nombrefichero
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextFile(filepath, 1)
strContents = objTS.ReadAll
objTS.Close

'addchat vbred,strContents 

arrLines = Split(strContents, vbNewLine)
Set objTS = objFS.OpenTextFile(filepath, 2)



encuentra = "no"
For Each strLine In arrLines
  
   If Not(Left(UCase(LTrim(strLine)),Len(strCheckForString)) = strCheckForString) Then        
      if trim(strLine) <> "" then 
		objTS.WriteLine strLine
      else
		encuentra = "si"
      end if	
   End If
Next

call leerfriends("no")

if encuentra = "si" then
	addq "/emote >>> DoNe <<< LisT UpdateD | Total Friends: " &  Totalfriends
else
	addq "/emote >>> NOT FOUND <<<  | Total Friends: " & Totalfriends 
end if

end sub