Help getting out of infinite roomsend function call

You can talk about VB programming here

Help getting out of infinite roomsend function call

Postby method » Sat May 27, 2006 10:04 am


Hi all i use this code to check for a certain word if it posted in room and if a certain room is posted in room i post back a customed massage. The current code sends infinite massages when a specific word is posted. Could any one tell me what i am doing wrong to just want post back one time instead of infinit times.Thanks

Code: Select all
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub


Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 10
End Sub

Private Sub Timer1_Timer()
On Error Resume Next
[B]Call LastChatLine[/B]
Call usertext
Call username
Text2 = Replace(Text2, Chr(10), "")
End Sub



modeule code

Code: Select all
Option Explicit
....
....
....

Function LastChatLine()

On Error Resume Next
Dim LastLine
Dim lastlen
Dim TheChatText As String
Dim TheChars As String
Dim TheChar As String
Dim FindChar
Dim ChatText As String
ChatText$ = GetChatText
For FindChar = 1 To Len(ChatText$)
TheChar$ = Mid(ChatText$, FindChar, 1)
TheChars$ = TheChars$ & TheChar$
If TheChar$ = Chr(13) Then
TheChatText$ = Mid(TheChars$, 1, Len(TheChars$) - 1)
Form1.RichTextBox1.Text = TheChatText$
'i added this line
Form1.Text4.Text = TheChatText$



Dim txt
txt = TheChatText$
If InStr(1, txt, "david") > 0 Then
Form1.Text4.Text = Replace(txt, "david", "some one mentioned u name")
'form1.Timer1.Enabled = False
Call Send("send this massage")===> this is called infinite times!!
txt = ""
'form1.Timer1.Enabled = True



End If

TheChars$ = ""
End If
Next FindChar
lastlen = Val(FindChar) - Len(TheChars$)
LastLine = Mid(ChatText$, lastlen, Len(TheChars$))
LastChatLine = LastLine
End Function
method
imFiles Master
imFiles Master
 
Posts: 686
Joined: Tue Oct 18, 2005 11:12 am

Postby BattleStar-Galactica » Sat May 27, 2006 5:24 pm

I read your post and if I undertand you want to do something like this>>>

1 get a whole last line
2 validate if the last line has your keyword already defined
3 send custom message like when you found f***** you will send blablabla this room is rate G some blalbabla are not permited blabla hey :lol:

I'm quite busy, if you dont figure it out one day I have time i will do example for U
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Postby method » Sat May 27, 2006 5:58 pm

nanomachine007 wrote:I read your post and if I undertand you want to do something like this>>>

1 get a whole last line
2 validate if the last line has your keyword already defined
3 send custom message like when you found f***** you will send blablabla this room is rate G some blalbabla are not permited blabla hey :lol:

I'm quite busy, if you dont figure it out one day I have time i will do example for U


Thank u for u reply. Yes that is what i want to do . But each time i get in to infinite loops and the massage get sent over and over ... . i be happy if u show me how to fix it.Thanks
method
imFiles Master
imFiles Master
 
Posts: 686
Joined: Tue Oct 18, 2005 11:12 am

Postby BattleStar-Galactica » Sat May 27, 2006 6:07 pm

mabye your problem is this>>> when your bot check 'david' and it will send david someone talk to you

that line still has david keyword so the bot will re-send again the message. to fix that just send a x line after send that message or a flower after your message is sent :lol:
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Postby method » Sat May 27, 2006 6:40 pm

nanomachine007 wrote:mabye your problem is this>>> when your bot check 'david' and it will send david someone talk to you

that line still has david keyword so the bot will re-send again the message. to fix that just send a x line after send that message or a flower after your message is sent :lol:


well i tought about that and the massage that i send has no word david . it has just the sentence some one mentioned your name .Also the name that i in the room is not david either. So there is no way that still finds david .

After i put that sendroom line problem comes. It either postes infinite time without even some one post the david word!! but if i remove the line i see in my test textbox it detect david and changes it to another sentence so that is not the problem!! try to run the code see what i am talking.





Code: Select all
If InStr(1, txt, "david") > 0 Then

Form1.Text4.Text = Replace(txt, "david", "some one mentioned u name")

'form1.Timer1.Enabled = False

Call Send("send this massage")===> infinite times!!

txt = ""

'form1.Timer1.Enabled = True

End If
method
imFiles Master
imFiles Master
 
Posts: 686
Joined: Tue Oct 18, 2005 11:12 am

Postby BattleStar-Galactica » Sun May 28, 2006 3:09 am

ok here it the example i promised you, check it out

well what it does in this example, it show you how to check the word in last line you got and it will send custom message when the keyword is found.
Attachments
checkcustomeword.rar
(2.26 KiB) Downloaded 59 times
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide

Postby method » Sun May 28, 2006 3:56 am

Many Many thanks for u nice code.


May i know how to add user name on post back who posted the search word ?
method
imFiles Master
imFiles Master
 
Posts: 686
Joined: Tue Oct 18, 2005 11:12 am

Postby BattleStar-Galactica » Sun May 28, 2006 4:42 pm

method wrote:Many Many thanks for u nice code.


May i know how to add user name on post back who posted the search word ?



when you get the last line, your line something like this>>>
username: usertextchat
you have just do a substring to get the username and oh yeah you can put more keyword like this keyword1;keywork2,keyword3....
and use function split to split in a tempory table and use loop statement like for or while what ever you prefer :lol:

hint for substring, use instr to find the first position of : and use Left function to get username. I don't play a lot with vb6 I don't know if there are other function better than these two functions I give you.

request loco for source code for do that, I think loco can do it quicky :lol:
User avatar
BattleStar-Galactica
imFiles Master
imFiles Master
 
Posts: 565
Joined: Tue Sep 20, 2005 12:19 am
Location: safest place to hide


Return to Visual Basic Programming

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests