所以在我试图使一个CMS系统,利用雅虎通讯SDK。这个想法是让自助机器人能够引导客户解决某些问题。会话通过两种方法运行。一个脚本存在以回应一般性回应。在客户收到的每条消息中,程序将查找certan关键字和问题,这些问题会触发XML文件的响应。如果它找到一个它继续与脚本。该计划的工作,但需要付出代价。它是一个巨大的资源。在这个程序中,我有一个类来处理所有的yahoo messenger函数,比如登录,注销,接收和发送消息。我也有一堂课,我称之为对话。这样可以保证消息来源的形式,发生的原因以及在脚本对话中的位置。在我的主要计划中,我根据有多少不同的网站帮助会计师使用我的初始X客户类。每次它收到一条消息时,它都会创建一个新的会话类,因为它存在或它检查现有会话并找到坐标位置。它显然也会对传入消息中的关键字进行所有检查。这是我用于接收消息的共享事件处理程序的代码。我的问题是,有没有办法让这个更有效率。资源和效率
Private Sub yahooclients_OnRec(ByVal sender As Object, ByVal buddy As String, ByVal message As String)
TotalRec = TotalRec + 1
Try
Dim c As YahooClient = CType(sender, YahooClient) 'Yahoo Client To Send Message From
showLog("From:" & buddy & " To:" & c.Account & " Message:" & message)
Dim msgSplit As String()
Dim retmsg As String
Dim smsg As String()
Dim n1 As XmlNode
Dim sran As New Random 'Random SPlit Message
Dim domran As New Random 'Random Domain ID
Dim Found1 As Boolean = False
Dim FoundIt As Integer = 0
Dim i As Integer = 0 'Keyword Counter
'Check Message For KeyWords By Splitting Each phrase by spaces
msgSplit = Split(message, " ")
For Each word In msgSplit
For Each value In KeywordInd
If value = word Then
n1 = m_nodelist.Item(i)
retmsg = n1.InnerText
GoTo ScrubMessage
End If
i = i + 1
Next
i = 0
Next
'Check For Conversations
If convos.Count = 0 Then
convos.Add(New Conversation(c.Account, buddy, 0))
retmsg = Script(0)
GoTo ScrubMessage
Else
For A As Integer = 0 To (convos.Count - 1)
If InStr(convos(A).TUser, c.Account) > 0 And InStr(convos(A).FUser, buddy) > 0 Then
Found1 = True
Exit For
End If
FoundIt = FoundIt + 1
Next
If Found1 = True Then
convos(FoundIt).SPosition = convos(FoundIt).SPosition + 1
'Send Next Position In Script
If convos(FoundIt).SPosition > (Script.Length - 1) Then
If convos(FoundIt).SPosition = Script.Length Then
TotalScript = TotalScript + 1
ToolStripStatusLabel10.Text = TotalScript
End If
Exit Sub
End If
retmsg = Script(convos(FoundIt).SPosition)
GoTo ScrubMessage
Else
convos.Add(New Conversation(c.Account, buddy, 0))
retmsg = Script(0)
GoTo ScrubMessage
End If
End If
ScrubMessage: “去掉| SMSG =斯普利特(retmsg,“|”)
'Pull A Random Response
If smsg.Length > 1 Then
retmsg = smsg(sran.Next(0, (smsg.Length) - 1))
Else
retmsg = smsg(0)
End If
'Check For Domain Indicator
If InStr(retmsg, "%") > 0 Then
TotalLink = TotalLink + 1
End If
retmsg = Replace(retmsg, "%s", Domains(domran.Next(0, (Domains.Length - 1))))
If CheckBox2.Checked = True Then 'send Message With Font and Color
retmsg = "<font face=" & """" & fname & """" & ">" & "[#FF80C0m" & retmsg & "</font>"
End If
showLog(("Sending Message: " & retmsg & " To: " & buddy & " From: " & c.Account))
c.SendMessage(buddy, retmsg)
TotalSent = TotalSent + 1
ToolStripStatusLabel4.Text = TotalSent 'Updates Sent Counter
ToolStripStatusLabel6.Text = TotalRec 'Updates Rec Counter
ToolStripStatusLabel8.Text = TotalLink 'Updates Links counter
Catch ex As Exception
showLog(ex.ToString)
End Try
End Sub
程序变为真的很多账目没有resonsive都在问的问题等
非常感谢提示! – 2011-01-13 21:24:50