jhylands

LIRA 1.0

Jan 24th, 2012
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.13 KB | None | 0 0
  1. Module Module1
  2.  
  3.     Sub Main()
  4.         Dim user As String
  5.         Dim bot As String
  6.         Do
  7.             user = Console.ReadLine()
  8.             Do Until bot <> "" Or user = ""
  9.                 bot = botresponse(user)
  10.                 user = Mid(user, 1, Len(user) - 1)
  11.             Loop
  12.             If bot = "" Then
  13.                 Console.WriteLine("I don't know")
  14.             ElseIf InStr(bot, "today is") Then
  15.                 Console.WriteLine("It's " & Day(Now) & " of " & MonthName(Month(Now)) & " today.")
  16.             Else
  17.  
  18.                 Console.WriteLine(bot)
  19.             End If
  20.             bot = ""
  21.         Loop
  22.  
  23.     End Sub
  24.     Public Function PostHTTPWebrequest(ByVal URL As String, ByVal PostData As String) As String
  25.         Dim encoding As New System.Text.UTF8Encoding
  26.         Dim byteData As Byte() = encoding.GetBytes(postdata)
  27.         Dim request As System.Net.HttpWebRequest
  28.         request = DirectCast(Net.HttpWebRequest.Create(URL), Net.HttpWebRequest)
  29.         request.Method = "POST"
  30.         request.ContentType = "application/x-www-form-urlencoded"
  31.         request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
  32.         request.ContentLength = byteData.Length
  33.         Dim postreqstream As System.IO.Stream = request.GetRequestStream()
  34.         postreqstream.Write(byteData, 0, byteData.Length)
  35.         postreqstream.Close()
  36.         Dim response As System.Net.HttpWebResponse
  37.         response = DirectCast(request.GetResponse(), Net.HttpWebResponse)
  38.         Dim postreqreader As New System.IO.StreamReader(response.GetResponseStream())
  39.         PostHTTPWebrequest = postreqreader.ReadToEnd
  40.     End Function
  41.     Public Function botresponse(ByVal user As String) As String
  42.         Dim bot As String
  43.         bot = PostHTTPWebrequest("http://78.47.186.254/simpleq.php", "hi=" & user)
  44.         bot = Mid(bot, (InStr(bot, ">")) + 1)
  45.         Do Until Mid(bot, 1, 1) <> Chr(13) And Mid(bot, 1, 1) <> Chr(10)
  46.             bot = Mid(bot, 2)
  47.         Loop
  48.         bot = Mid(bot, 1, InStr(bot, "<") - 1)
  49.         botresponse = bot
  50.     End Function
  51. End Module
Advertisement
Add Comment
Please, Sign In to add comment