IPB

Welcome Guest ( Log In | Register )

2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 
Reply to this topicStart new topic
> Custom Commands?
AENEMA
post Sep 25 2009, 02:50 PM
Post #1


Rookie
*

Group: Members
Posts: 4
Joined: 23-April 07
Member No.: 22,765



Hello,

It's been a while since I used any chat bots, about 5 years, so bare with me please.

I'm working on setting up a channel for Diablo 2. Its going to be a private dueling community. I want to add a command so that people with enough access can post new games to the bot and so others can get the list of current games that are up. Is this possible?

Please help point me in the right direction. Thanks!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Spiritless
post Sep 26 2009, 12:10 AM
Post #2


Me 1337 plz??
**

Group: Members
Posts: 58
Joined: 25-July 09
From: My home?
Member No.: 52,816



To make sure I understand correctly:

Someone adds a game to a list...
Someone else can view a list of current games...
When a game ends they take the game off the list...

Correct?


--------------------
IPB Image
-OverLord of Flame Spiritless_One - Legion of Flame -- Welcome to the Legion
www.LoF-Legion.tk
IPB Image
IPB Image

Ѕףﺃѓїtlۼss_Ộ∩
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
AENEMA
post Sep 28 2009, 05:44 PM
Post #3


Rookie
*

Group: Members
Posts: 4
Joined: 23-April 07
Member No.: 22,765



QUOTE(Spiritless @ Sep 26 2009, 02:10 AM) *

To make sure I understand correctly:

Someone adds a game to a list...
Someone else can view a list of current games...
When a game ends they take the game off the list...

Correct?


100%

Any ideas?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
The-Black-Ninja
post Sep 28 2009, 06:47 PM
Post #4


Pure Sex
********

Group: Moderators
Posts: 7,756
Joined: 13-August 06
Member No.: 7,372



Please don't bump. Someone will get to this when they have the time. If no one can, or no one has the time, you're outta luck sad.gif


--------------------
IPB Image

-My Plugins :: Thanks Pyro :)
IPB ImageIPB Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Fallen-God
post Sep 29 2009, 01:42 PM
Post #5


Full Member
***

Group: Members
Posts: 120
Joined: 30-May 08
Member No.: 37,466



How will the bot detect when the game has ended?
I could make it so it is on a timer and/or a gamedel command.
If that's okay then I can make this script.

I have made a script which achieves this, but for some reason it errors in the way described below:

Things that should happen are in green, things that shouldn't are in red


When someone tries to add a game to the list:
QUOTE
<Fallen-God[LcR]> !gameadd hio
<ClanBoT[LcR]> The game [hio] has been added to the game list.

UserTalk Call Error On File> C:\Program Files\StealthBot\plugins\Gamelist.txt
Error Number: 13 Description: Type mismatch

<Fallen-God[LcR]> !gameadd hio
<ClanBoT[LcR]> A game with that name is already on the list.



A similar story with the !gemedel command. It says it has deleted the entry/there is no entry by that name, but it errors when it tries to do anything to the dictionary.

When someone tries to list the games:
QUOTE
<Fallen-God[LcR]> !listgames
UserTalk Call Error On File> C:\Program Files\StealthBot\plugins\Gamelist.txt
Error Number: 13 Description: Type mismatch

Once again; anything to do with the dictionary errors.



If someone could tell me why this happens that'd be great.
Thanks.

Oh, here is the script:
CODE
'GLS
'1.0
'Game List Script:Fallen-God

Private Const gls_Gameadd = "Gameadd"         'Command to add a game to the list
Private Const gls_Gamedel = "Gamedel"         'Command to remove a game to the list
Private Const gls_Gamelist = "Listgames"      'Command to list all of the added games
Private Const glsInterval = 60                'Time (minutes) before a game is removed from the list

Private gls_gameDic                 'Declare dictionary variable
Private gls_GameArr                 'Declare the Gamelist Array
Private gls_Output                  'Declare the bot output for the Gamelist

Sub GLS_Event_Load()
   Set gls_gameDic = CreateObject("Scripting.Dictionary")
End Sub

Sub GLS_Event_Usertalk(Username, Flags, Message, Ping)
   GLS_ProcessInput Username, Message, 1
End Sub

Sub GLS_Event_WhisperFromUser(Username, Flags, Message)
   GLS_ProcessInput Username, Message, 3
End Sub

Sub GLS_ProcessInput(Username, Message, DspId)
   If Left(LCase(Message),Len(gls_Gameadd)+1) = BotVars.Trigger & LCase(gls_Gameadd) Then
      gls_Inputsplit = Split(Message, " ", 2)(1)
      If gls_gameDic.Exists(gls_Inputsplit) Then
         AddQ "A game with that name is already on the list."
         Exit Sub
      End If
      gls_gameDic.Add gls_Inputsplit, Now
      AddQ "The game [" & gls_Inputsplit & "] has been added to the game list."
   End If
  
   If Left(LCase(Message),Len(gls_Gamedel)+1) = BotVars.Trigger & LCase(gls_Gamedel) Then
      gls_Inputsplit = Split(Message, " ", 2)(1)
      If Not gls_gameDic.Exists(gls_Inputsplit) Then
         AddQ "That game does not appear on the list."
         Exit Sub
      End If
      gls_gameDic.Remove(gls_Inputsplit)
      AddQ "The game [" & gls_Inputsplit & "] has been removed from the game list."
   End If
  
   If Left(LCase(Message),gls_Gamelist+1) = BotVars.Trigger & LCase(gls_Gamelist) Then
      gls_Output = "Current games"
      gls_GameArr = gls_gameDic.Keys
      
      If UBound(gls_GameArr) < 0 Then
         AddQ "There are currently no games on the list."
         Exit Sub
      End If
      
      For i = 0 to UBound(gls_GameArr)  
         If DateDiff("n", gls_gameDic.Item(gls_GameArr(i)), Now) > glsInterval Then gls_gameDic.Remove(gls_GameArr(i))
      Next
      
      gls_GameArr = gls_gameDic.Keys
      
      For i = 0 to UBound(gls_GameArr)
         gls_Output = gls_Output & ": Game( " & i+1 & "): " & gls_GameArr(i) & ":"
      Next
      AddQ gls_Output
   End If
End Sub



--------------------
QUOTE
Most active topic:
Trash Can
( 17 posts / 57% of this member's active posts )

Lol.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
The-Black-Ninja
post Sep 29 2009, 02:18 PM
Post #6


Pure Sex
********

Group: Moderators
Posts: 7,756
Joined: 13-August 06
Member No.: 7,372



Use:
CODE
gls_gameDic.Item(gls_Inputsplit) = Now

Also, don't use brackets in your .Remove stuff:
CODE
gls_gameDic.Remove gls_Inputsplit
In the list games sub, you should be checking if there are any games left AFTER the for loop because that loop is removing games as well.


--------------------
IPB Image

-My Plugins :: Thanks Pyro :)
IPB ImageIPB Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Fallen-God
post Sep 29 2009, 03:22 PM
Post #7


Full Member
***

Group: Members
Posts: 120
Joined: 30-May 08
Member No.: 37,466



Thanks and thanks.
Why can't I use brackets? Because after seeing you use the Dictionary for the anti-spam I read up about it and their examples used brackets.


--------------------
QUOTE
Most active topic:
Trash Can
( 17 posts / 57% of this member's active posts )

Lol.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
The-Black-Ninja
post Sep 29 2009, 03:51 PM
Post #8


Pure Sex
********

Group: Moderators
Posts: 7,756
Joined: 13-August 06
Member No.: 7,372



You can't use brackets for when you remove an item.


--------------------
IPB Image

-My Plugins :: Thanks Pyro :)
IPB ImageIPB Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Fallen-God
post Sep 29 2009, 04:10 PM
Post #9


Full Member
***

Group: Members
Posts: 120
Joined: 30-May 08
Member No.: 37,466



Still doesn't work.
I think I changed it all right.

CODE
'GLS
'1.0
'Game List Script:Fallen-God

Private Const gls_Gameadd = "Gameadd"         'Command to add a game to the list
Private Const gls_Gamedel = "Gamedel"         'Command to remove a game to the list
Private Const gls_Gamelist = "Listgames"      'Command to list all of the added games
Private Const glsInterval = 60                'Time (minutes) before a game is removed from the list

Private gls_gameDic                 'Declare dictionary variable
Private gls_GameArr                 'Declare the Gamelist Array
Private gls_Output                  'Declare the bot output for the Gamelist

Sub GLS_Event_Load()
   Set gls_gameDic = CreateObject("Scripting.Dictionary")
End Sub

Sub GLS_Event_Usertalk(Username, Flags, Message, Ping)
   GLS_ProcessInput Username, Message, 1
End Sub

Sub GLS_Event_WhisperFromUser(Username, Flags, Message)
   GLS_ProcessInput Username, Message, 3
End Sub

Sub GLS_ProcessInput(Username, Message, DspId)
   If Left(LCase(Message),Len(gls_Gameadd)+1) = BotVars.Trigger & LCase(gls_Gameadd) Then
      gls_Inputsplit = Split(Message, " ", 2)(1)
      If gls_gameDic.Exists(gls_Inputsplit) Then
         AddQ "A game with that name is already on the list."
         Exit Sub
      End If
      gls_gameDic.Item(gls_Inputsplit) = Now
      AddQ "The game [" & gls_Inputsplit & "] has been added to the game list."
   End If
  
   If Left(LCase(Message),Len(gls_Gamedel)+1) = BotVars.Trigger & LCase(gls_Gamedel) Then
      gls_Inputsplit = Split(Message, " ", 2)(1)
      If Not gls_gameDic.Exists(gls_Inputsplit) Then
         AddQ "That game does not appear on the list."
         Exit Sub
      End If
      gls_gameDic.Remove gls_Inputsplit
      AddQ "The game [" & gls_Inputsplit & "] has been removed from the game list."
   End If
  
   If Left(LCase(Message),gls_Gamelist+1) = BotVars.Trigger & LCase(gls_Gamelist) Then
      gls_Output = "Current games"
      gls_GameArr = gls_gameDic.Keys
      
      For i = 0 to UBound(gls_GameArr)  
         If DateDiff("n", gls_gameDic.Item(gls_GameArr(i)), Now) > glsInterval Then gls_gameDic.Remove gls_GameArr(i)
      Next
      
      If UBound(gls_GameArr) < 0 Then
         AddQ "There are currently no games on the list."
         Exit Sub
      End If
      
      gls_GameArr = gls_gameDic.Keys
      
      For i = 0 to UBound(gls_GameArr)
         gls_Output = gls_Output & ": Game( " & i+1 & "): " & gls_GameArr(i) & ":"
      Next
      
      AddQ gls_Output
   End If
End Sub


--------------------
QUOTE
Most active topic:
Trash Can
( 17 posts / 57% of this member's active posts )

Lol.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
The-Black-Ninja
post Sep 29 2009, 06:47 PM
Post #10


Pure Sex
********

Group: Moderators
Posts: 7,756
Joined: 13-August 06
Member No.: 7,372



Is this what you're more/less trying to do?
CODE
'GLS
'1.0
'Game List Script:Fallen-God

Private Const gls_Gameadd = "Gameadd"         'Command to add a game to the list
Private Const gls_Gamedel = "Gamedel"         'Command to remove a game to the list
Private Const gls_Gamelist = "Listgames"      'Command to list all of the added games
Private Const glsInterval = 60                'Time (minutes) before a game is removed from the list

Private gls_gameDic                 'Declare dictionary variable
Private gls_GameArr                 'Declare the Gamelist Array
Private gls_Output                  'Declare the bot output for the Gamelist

Sub GLS_Event_Load()
   Set gls_gameDic = CreateObject("Scripting.Dictionary")
End Sub

Sub GLS_Event_Usertalk(Username, Flags, Message, Ping)
   GLS_ProcessInput Username, Message, 1
End Sub

Sub GLS_Event_WhisperFromUser(Username, Flags, Message)
   GLS_ProcessInput Username, Message, 3
End Sub

Sub GLS_Event_PressedEnter(Text)
   GLS_ProcessInput BotVars.Username, Text, 4
End Sub

Sub GLS_ProcessInput(Username, Message, DspId)

   If dspId = 4 Then
      If Left(Message, 1) <> "/" Then Exit Sub
   Else
      If Left(LCase(Message), Len(BotVars.Trigger)) <> BotVars.Trigger Then Exit Sub
   End If
  
   msg = Mid(Message, Len(BotVars.Trigger)+1)
   cmd = Split(Lcase(msg))(0)
    
   If cmd = LCase(gls_Gameadd) Then
      gls_Inputsplit = Split(msg, " ", 2)(1)
      If gls_gameDic.Exists(gls_Inputsplit) Then
         AddQ "A game with that name is already on the list."
         Exit Sub
      End If
      gls_gameDic.Item(gls_Inputsplit) = Now
      AddQ "The game [" & gls_Inputsplit & "] has been added to the game list."
   End If
  
   If cmd = LCase(gls_Gamedel) Then
      gls_Inputsplit = Split(msg, " ", 2)(1)
      If Not gls_gameDic.Exists(gls_Inputsplit) Then
         AddQ "That game does not appear on the list."
         Exit Sub
      End If
      gls_gameDic.Remove gls_Inputsplit
      AddQ "The game [" & gls_Inputsplit & "] has been removed from the game list."
   End If
  
   If cmd = LCase(gls_Gamelist) Then
      gls_Output = "Current games: "
      gls_GameArr = gls_gameDic.Keys
            
      If UBound(gls_GameArr) < 0 Then
         AddQ "There are currently no games on the list."
         Exit Sub
      End If      
      
      For i = 0 to UBound(gls_GameArr)
         If DateDiff("n", gls_gameDic.Item(gls_GameArr(i)), Now) > glsInterval Then
            gls_gameDic.Remove gls_GameArr(i)
         Else
            text = text & "Game(" & i+1 & "): " & gls_GameArr(i) & ":"
         End If
      Next
        
      If text <> vbNullString Then
         AddQ gls_Output & Left(text, Len(text) -1)
      Else
         AddQ "There are currently no games on the list."
      End If
   End If
End Sub


--------------------
IPB Image

-My Plugins :: Thanks Pyro :)
IPB ImageIPB Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
AENEMA
post Sep 29 2009, 10:07 PM
Post #11


Rookie
*

Group: Members
Posts: 4
Joined: 23-April 07
Member No.: 22,765



Thanks for the help guys! I'll have to give the script a try tomorrow. Been a long day. Sorry for the bump! wasn't sure if there was a bump rule or not.

I appreciate all the help guys. Awesome.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Fallen-God
post Sep 30 2009, 01:56 PM
Post #12


Full Member
***

Group: Members
Posts: 120
Joined: 30-May 08
Member No.: 37,466



Thanks Ninja.
I have edited the script to do the following commands (names can be changed):

!gameadd <Name> Add a game with <Name>

!gamedel <Name/Number> - Delete a game by name or by game number

!getgame <Number/Name> - Returns the name of the game and the amount of time passed since the game was added to the script (to the nearest minute)

!listgames - Lists the names and numbers of all games

!clearlist - Clears the whole list of games.


I have also change it to have 3 access requirements:
Access to view games
Access to add games
Access to delete games

If you want I will also change it to record the maker of the game, but I will wait to see if you actually want this before I go ahead.

Oh and also I have changed the AddQ's to Dsp DspIds so it supports effectively adding/deleting/viewing games view whisper.
(It did this before but people not in the channel would not be able to see the reply)


--------------------
QUOTE
Most active topic:
Trash Can
( 17 posts / 57% of this member's active posts )

Lol.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Neco
post Sep 30 2009, 04:51 PM
Post #13


Rookie
*

Group: Members
Posts: 7
Joined: 11-August 09
From: New Zealand
Member No.: 53,346



Any chance of someone adapting this script for Warcraft III? Or will it work already?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
The-Black-Ninja
post Sep 30 2009, 05:05 PM
Post #14


Pure Sex
********

Group: Moderators
Posts: 7,756
Joined: 13-August 06
Member No.: 7,372



What I posted will work for WC3 as is.


--------------------
IPB Image

-My Plugins :: Thanks Pyro :)
IPB ImageIPB Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 16th September 2019 - 12:12 AM
Skin by Andrea
Website Legal Information | Hosted by LunarPages