can anyone help please with this bulletin script

Which hub software is the best? Where can I find script XXX? Discuss it here...(no, this is not for advertising your hub...)

Moderator: Moderators

Locked
shaun.scargall
Posts: 6
Joined: 2003-09-22 11:06

can anyone help please with this bulletin script

Post by shaun.scargall » 2003-09-29 04:08

i have had this bulletin script running for some time now and it is very good but i would like to change it so it opens in a private message window as i have an quizz running in the main chat window so as the quizz is running you carn't read the bulletin board because the chat window is on the move all the time . many thanks shaun


'Bulletin Script 1.0 by Gadget <[email protected]> http://gadget.no-ip.info
'If script wont work, check out that you installed hub software using proper installer
'and that your antivirus software is not blocking scripts which try to access files.
Dim sBotName,sFileName,iExpireTime,aModerators,bUsersCanAdd,bOpOnly,iMinLenght,iMaxLenght,iInterval,sEntries,iCount,sLast,sAdder,iTicker

Sub Main()
sBotName = "Bulletin Board" '<- The bot's name.
sFileName = "bulletindata.txt" '<- Filename where entries will be saved.
iExpireTime = 60 '<- Expiration of added messages in days.
aModerators = Array("junrrocker","poppit","bluecap") '<- List of moderators who can remove entries sent by other users or clear all entries.
bUsersCanAdd = True '<- True if you want users be able to add messages to Bulletin, False if only ops can.
bOpOnly = False '<- True if operators only can use the Bulletin, False if it's for all users.
iMinLenght = 5 '<- Minimum lenght of message in characters.
iMaxLenght = 1000 '<- Maximum lenght of message in characters.
iInterval = 0 '<- Minimum interval in minutes how often users can add new messages.

sEntries=DelOld(ReadFile(sFileName))
sAdder=""
frmHub.RegisterBotName cStr(sBotName)
iTicker=0
tmrScriptTimer.Interval=60000
tmrScriptTimer.Enabled=True
End Sub

Sub DataArival(curUser,sCurData)
If Left(sCurData,1)="<" Or Left(sCurData,Len(sBotName)+6)="$To: "+sBotName+" " Then
sCmd=Mid(sCurData,InStr(sCurData,">")+2)
sText=""
If InStr(sCmd," ") Then
sText=Mid(sCmd,InStr(sCmd," ")+1)
sCmd=Left(sCmd,InStr(sCmd," ")-1)
End If
sReply=""
Select Case LCase(sCmd)
Case "-read"
If (Not curUser.bOperator And Not bIsModerator(curUser.sName)) And bOpOnly Then
sReply="This bulletin is for operators and moderators only."
Else
If iCount>0 Then
sReply="Welcome to Bulletin. There are "+CStr(iCount)+" messages:"+vbCrLf+vbCrLf+Parse(sEntries)
sReply=sReply+vbCrLf+"--------------------"+vbCrLf+"Report unwanted messages to some of the moderators: "+Join(aModerators,", ")
Else
sReply="There are no messages in Bulletin."
End If
If bUsersCanAdd Or curUser.bOperator Or bIsModerator(curUser.sName) Then
If bIsModerator(curUser.sName) Then
sReply=sReply+vbCrLf+"You can add messages with '-add <message>', remove messages with '-remove <start of message/date>' and remove all messages with '-removeall'."
Else
sReply=sReply+vbCrLf+"You can add messages with '-add <message>' and remove your messages with '-remove <start of message/date>'."
End If
End If
End If
Case "-add"
If sAdder=curUser.sName Then
sReply="You just added a message. Please wait "+CStr(iInterval)+" minutes and try again."
ElseIf Not curUser.bOperator And Not bIsModerator(curUser.sName) And (bOpOnly Or Not bUsersCanAdd) Then
sReply="Only operators or moderators can add messages to Bulletin."
ElseIf Len(sText)<iMinLenght Then
sReply="Your message was not added because it is too short."
ElseIf Len(sText)>iMaxLenght Then
sReply="Your message was not added because it is too long."
ElseIf InStr(sText,"[Added ") Then
sReply="Do not try to fake messages!"
Else
sAdder=curUser.sName
sEntries=DelOld(sEntries+vbCrLf+Replace(sText,vbCrLf,"\n")+"|"+curUser.sName+"|"+CStr(Now()))
Call WriteFile(sFileName,sEntries)
sReply="Your message is now added."
If bOpOnly Then
For each user in colUsers
If user.bOperator Or bIsModerator(curUser.sName) Then user.SendData CStr("<"+sBotName+"> "+curUser.sName+" just added new message. Type '-read' in main chat or privately to "+sBotName+" to read it.")
Next
Else
colUsers.SendChatToAll CStr(sBotName),CStr(curUser.sName+" just added new message. Type '-read' in main chat or privately to "+sBotName+" to read it.")
End If
End If
Case "-remove"
If Not curUser.bOperator And Not bIsModerator(curUser.sName) And (bOpOnly Or Not bUsersCanAdd) Then
sReply="Only operators or moderators can remove messages from Bulletin."
ElseIf sText="" Then
sReply="Specify beginning of text or date of message you want to remove."
Else
aEntries=Split(sEntries,vbCrLf)
For i=0 To UBound(aEntries)
aEntry=Split(aEntries(i),"|")
If UBound(aEntry)=2 Then
If LCase(sText)=LCase(Left(aEntry(0),Len(sText))) or LCase(sText)=LCase(Left(aEntry(2),Len(sText))) Then
If LCase(curUser.sName)=LCase(aEntry(1)) Or bIsModerator(curUser.sName) Then
sReply="Following message was removed:"+vbCrLf+Parse(aEntries(i))
aEntries(i)=""
sEntries=DelOld(Join(aEntries,vbCrLf))
Call WriteFile(sFileName,sEntries)
Exit For
Else
sReply="Only moderators can remove messages sent by other users!"
End If
End If
End If
Next
If sReply="" Then sReply="Couldn't find that message."
End If
Case "-removeall"
If Not bIsModerator(curUser.sName) Then
sReply="Only moderators can remove all messages."
Else
sEntries=DelOld("")
Call WriteFile(sFileName,sEntries)
sReply="All messages have been removed."
End If
End Select
If sReply<>"" Then
If Left(sCurData,1)="<" Then
curUser.SendData CStr("<"+sBotName+"> "+sReply)
Else
curUser.PrivateMessage CStr(sBotName),cStr(sReply)
End If
End If
End If
End Sub

Sub NewUserConnected(curUser)
If curUser.bOperator Or bIsModerator(curUser.sName) Or Not bOpOnly Then
If iCount>0 Then
curUser.SendData CStr("<"+sBotName+"> There are "+CStr(iCount)+" messages in Bulletin, last was added "+sLast+". Type '-read' in main chat or privately to "+sBotName+" to read messages.")
Else
curUser.SendData CStr("<"+sBotName+"> There are no messages in Bulletin. Type '-read' in main chat or privately to "+sBotName+" to get instructions how to add messages.")
End If
End If
End Sub

Sub OPConnected(curUser)
Call NewUserConnected(curUser)
End Sub

Sub tmrScriptTimer_Timer()
iTicker=iTicker+1
If iTicker=>iInterval Then
iTicker=0
sAdder=""
End If
End Sub

Function ReadFile(sFileName)
On Error Resume Next
Set fso=CreateObject("Scripting.FileSystemObject")
If fso.FileExists(sFileName) Then
Set file=fso.OpenTextFile(sFileName,1,True)
ReadFile=file.ReadAll
file.Close
Else
ReadFile="Welcome to Gadget's Bulletin!|"+sBotName+"|"+CStr(Now())
End If
End Function

Sub WriteFile(sFileName,sText)
Set fso=CreateObject("Scripting.FileSystemObject")
Set file=fso.CreateTextFile(sFileName,True)
file.Write(CStr(sText))
file.Close
End Sub

Function DelOld(sText)
DelOld=""
aEntries=Split(sText,vbCrLf)
iCount=0
For i=0 To UBound(aEntries)
aEntry=Split(aEntries(i),"|")
If UBound(aEntry)=2 Then
If DateDiff("d",aEntry(2),Now())<iExpireTime Then
If DelOld="" Then
DelOld=Join(aEntry,"|")
Else
DelOld=DelOld+vbCrLf+Join(aEntry,"|")
End If
iCount=iCount+1
sLast=aEntry(2)
End If
End If
Next
End Function

Function Parse(sText)
Parse=""
aEntries=Split(sText,vbCrLf)
iCount=0
For i=0 To UBound(aEntries)
aEntry=Split(aEntries(i),"|")
If UBound(aEntry)=2 Then
If DateDiff("d",aEntry(2),Now())<iExpireTime Then
If Parse="" Then
Parse=aEntry(0)+" [Added by "+aEntry(1)+" in "+aEntry(2)+"]"
Else
Parse=Parse+vbCrLf+"--------------------"+vbCrLf+aEntry(0)+" [Added by "+aEntry(1)+" in "+aEntry(2)+"]"
End If
iCount=iCount+1
sLast=aEntry(2)
End If
End If
Next
Parse=Replace(Parse,"\n",vbCrLf)
End Function

Function bIsModerator(sUser)
bIsModerator=False
For i=0 to UBound(aModerators)
If LCase(CStr(sUser))=LCase(CStr(aModerators(i))) Then bIsModerator=True
Next
End Function

HaArD
Posts: 147
Joined: 2003-01-04 02:20
Location: Canada http://hub-link.sf.net
Contact:

Post by HaArD » 2003-09-29 06:19

At the end of the "Sub DataArival", just before the "Sub NewUserConnected"

Code: Select all

If sReply<>"" Then 
''''''Comment out these 3 lines so that replies are always sent as PM's
''''''If Left(sCurData,1)="<" Then 
''''''curUser.SendData CStr("<"+sBotName+"> "+sReply) 
''''''Else 
curUser.PrivateMessage CStr(sBotName),cStr(sReply) 
End If 
End If 
End If 
End Sub 

Sub NewUserConnected(curUser) 
You will still be able to issue commands in Main Chat with this change.

To make Bulletin only accept commands in PM's as well, change the beginning of the "Sub DataArival" too:

Code: Select all

Sub DataArival(curUser,sCurData) 
''''''If Left(sCurData,1)="<" Or Left(sCurData,Len(sBotName)+6)="$To: "+sBotName+" " Then 
''''''Replace the above line with the one below
If Left(sCurData,Len(sBotName)+6)="$To: "+sBotName+" " Then 
sCmd=Mid(sCurData,InStr(sCurData,">")+2) 
HaArD

Locked