All pastes #155362 Raw Edit

Untitled

public text v1 · immutable
#155362 ·published 2006-08-31 00:41 UTC
rendered paste body
'secretary
'1.0
'%Secretary script: Yint & Echo.Defender
'&Read commands bellow to see how to run it.

'% Secretary script v1.0
'%	Written by: Yint & Echo.Defender
'%  Last modified by: Yint & Echo.Defender On: August 30, 2006.

'************************************
'*    Commands & Descriptions       *
'************************************

'//            Note Commands:
'.secretary NOTE: <note> This adds the note to the note list.
'.lists This shows the list of notes added.
'.clearall This clears all of the notes added.

'//           Description:
'//When a user joins the channel, the bot checks if he already saw him. If not, he will give him 

'flags K.  




Public notesFileName



notesFileName = "notes.txt"

const forReading = 1
const forWriting = 2
const forAppending = 8
dim fso
set fso = CreateObject("Scripting.FileSystemObject")




Sub secretary_event_PressedEnter(Text)
	Call secretary_event_UserTalk(myUsername, 0, Text, 0)
End Sub

Sub secretary_event_UserTalk(Username, Flags, Message, Ping)

 
if flags = "A" then  
if left(message,8) = BotVars.Trigger & "clearall" then 
   if fso.FileExists("notes.txt") = False then 
     addq "Cannot locate notes file." 
   else
     dim gr
     set gr = fso.OpenTextFile("notes.txt", ForWriting, 1)
     gr.close
     AddQ "The Notes File Has Been Cleared"
   End If
  End If
End if

 
	
	If Left(Message, 10) = BotVars.Trigger & "secretary" Then
	Call Appendtext(notesFileName, Right(Message, Len(Message) -10 ))
	AddQ "/me Your note has been added to the list."
	
		

	ElseIf Left(Message, 6) = BotVars.Trigger & "lists" Then
        	Call Listfile(notesFileName)




	End If

End Sub






Sub Listfile(filepath)
	Dim File, allNames, first

	Set File = FSO.OpenTextFile(filepath,1)
	first = "y"
	Do While Not File.AtEndOfStream
		If first = "y" then
			allNames = Trim(File.ReadLine)
			first = "n"
		Else 
			allNames = allNames & ", " & Trim(File.ReadLine)
		End If

	Loop
	File.Close

	AddChat vbGreen, allNames
	AddQ "/me " & allNames

End Sub




Sub AppendText(filepath,text)
	Dim File
	Set File = FSO.OpenTextFile(filepath,8,true)
	File.WriteLine text 
	File.Close
End Sub