Subversion Repositories HomeAutomation

Rev

Blame | Last modification | View Log | SVN | RSS feed

  1. function Eggdrop_Post(host, port, username, password, channel, text)
  2. {
  3.   var socket_id = Socket_Connect(host, port, function(socket_id, data)
  4.   {
  5.     /* When connected the host will first ask us for the username */
  6.     if (data.indexOf("Please enter your nickname") > -1)
  7.     {
  8.       Socket_Send(socket_id, username + "\n");
  9.     }
  10.     /* Then the host will ask us for the password */
  11.     if (data.indexOf("Enter your password") > -1)
  12.     {
  13.       Socket_Send(socket_id, password + "\n");
  14.     }
  15.     /* If credentials is correct we are connected */
  16.     if (data.indexOf("joined the party line") > -1)
  17.     {
  18.       Socket_Send(socket_id, ".say " + channel + " " + text + "\n");
  19.       Socket_Send(socket_id, ".quit\n");
  20.     }
  21.   }, function(socket_id, state)
  22.   {
  23.       /* No need to do anything on connection state change */
  24.   });
  25.    
  26.   return socket_id;
  27. }
  28.