News:

So the widespread use of emojis these days kinda makes forum smileys pointless, yeah?

Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Ryan Marcus

#16
General Programming / Re: Battle.net Instant Messenger!
January 02, 2006, 08:18:39 PM
I wrote about two years ago... pretty much retarted.
#17
Botdev / Re: Making Trivia Bot Hints
December 22, 2005, 08:48:13 AM
Not by itself, but I wrote a method that lets me do it.
#18
Botdev / Re: Making Trivia Bot Hints
December 20, 2005, 08:38:33 AM
Thanks everybody :)
#19
Botdev / Making Trivia Bot Hints
December 19, 2005, 10:21:16 PM
I'm adding a trivia feature to my bot... I just finished writing the code to create a hint based on a integer that is passed in called HintLevel.


  dim i, ii, iii as integer
  dim r as new Random
  dim Hint as string
 
  i = len(Answer)
  ii = 0
 
  while ii<>i + 1
    Hint = hint + "-"
    ii = ii + 1
  wend
 
  ii = 0
 
  while ii<>HintLevel + 1
    iii = r.InRange(1, i)
    Hint = left(hint, iii - 1) + mid(Answer, iii - 1, 1) + mid(hint, iii)
    ii = ii + 1
  Wend
 
  return hint


That should return dashs with HintLevel filled in characters... I have not tested it, but I am sure there is a better way to do it. Its in REALBasic, by the way.
#20
General Programming / Killall for PC
December 18, 2005, 01:39:05 PM
Is there an equivalent for the "killall" command on UNIX for the PC?
#21
That's the idea. It loops forever, because I can't figure out how to make code execute when a socket receives data.
#22
Ah! I see. Then where do you suggest I put that code? Its still in the class, so I thought it might be OK...
#23
Alright, after you read this it should be pretty obvious what it does:


[pre]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Properties;

import javax.swing.JComponent;

import callback_interfaces.PluginCallbackRegister;
import callback_interfaces.PublicExposedFunctions;
import callback_interfaces.StaticExposedFunctions;
import exceptions.PluginException;
import plugin_interfaces.ConnectionCallback;
import plugin_interfaces.EventCallback;
import plugin_interfaces.GenericPluginInterface;

public class PluginMain extends GenericPluginInterface implements EventCallback, ConnectionCallback
{

    private static ServerSocket serverSocket = null;

    private static Socket clientSocket = null;

    private static PrintWriter pOut = null;

    private static BufferedReader in = null;
    private static PublicExposedFunctions tOut = null;

    public void load(StaticExposedFunctions staticFuncs)
    {
       
    }

public void activate(PublicExposedFunctions out, PluginCallbackRegister register)
    {
    register.registerEventPlugin(this, null);
    register.registerConnectionPlugin(this, null);
    tOut = out;
    }
public void deactivate(PluginCallbackRegister register)
    {
        // TODO Auto-generated method stub

    }

    public String getName()
    {
        // TODO Auto-generated method stub
        return "SBCP";
    }

    public String getVersion()
    {
        // TODO Auto-generated method stub
        return "1.0";
    }

    public String getAuthorName()
    {
        // TODO Auto-generated method stub
        return "Ryan Marcus";
    }

    public String getAuthorWebsite()
    {
        // TODO Auto-generated method stub
        return "None";
    }

    public String getAuthorEmail()
    {
        // TODO Auto-generated method stub
        return "ryan@marcusfamily.info";
    }

    public String getLongDescription()
    {
        // TODO Auto-generated method stub
        return "Allows you to connect with SBCP";
    }

    public Properties getDefaultSettingValues()
    {
        // TODO Auto-generated method stub
        Properties p = new Properties();
        return p;
    }

    public Properties getSettingsDescription()
    {
        // TODO Auto-generated method stub
        Properties p = new Properties();
        return p;
    }

    public JComponent getComponent(String settingName, String value)
    {
        // TODO Auto-generated method stub
        return null;
    }

    public Properties getGlobalDefaultSettingValues()
    {
        // TODO Auto-generated method stub
        Properties p = new Properties();
        return p;
    }

    public Properties getGlobalSettingsDescription()
    {
        // TODO Auto-generated method stub
        Properties p = new Properties();
        return p;
    }

    public JComponent getGlobalComponent(String settingName, String value)
    {
        // TODO Auto-generated method stub
        return null;
    }
   
   
    public void talk(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
       pOut.println("TALK" + user + " " + statstring);
    }

    public void emote(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("EMOT" + user + " " + statstring);
    }

    public void whisperFrom(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("WSFM" + user + " " + statstring);
    }

    public void whisperTo(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("WSCN" + user + " " + statstring);
    }

    public void userShow(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("USIN" + user + " " + statstring);
    }

    public void userJoin(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("USJN" + user + " " + statstring);
    }

    public void userLeave(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("USLV" + user + " " + statstring);
    }

    public void userFlags(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("USFG" + user + " " + statstring);
    }

    public void error(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("ERRO" + user + " " + statstring);
    }

    public void info(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("INFO" + user + " " + statstring);
    }

    public void broadcast(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("BRDC" + user + " " + statstring);
    }

    public void channel(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("CHAN" + user + " " + statstring);
    }
   
    public final boolean ABORT = false;
    public final boolean CONTINUE = true;
   
    /** The bot is about to connect to a server, but hasn't yet.  At this point, the connection can be stopped. */
    public boolean connecting(String host, int port, Object data) throws IOException, PluginException
    {
        return false;
    }
    /** The bot has just connected to the server. */
    public void connected(String host, int port, Object data) throws IOException, PluginException
    {
       
       
       
        try {
            serverSocket = new ServerSocket(4444);
        } catch (IOException e) {
            System.err.println("Could not listen on port: 4444.");
            System.exit(1);
        }

   
        try
        {
            clientSocket = serverSocket.accept();
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
     

       
         
         
         try
        {
            pOut = new PrintWriter(clientSocket.getOutputStream(), true);
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
       
       
     
           
            try
            {
                in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
            }
            catch (IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
       
        pOut.println("Connected!");
       
       
           
    }
   
    /** The bot is about to disconnect from the server.  This is only called for planned disconnects. */
    public boolean disconnecting(Object data)
    {
        return false;
    }
    /** The bot has disconnected from the server. */
    public void disconnected(Object data)
    {
    }

   
    private static String inputLine = null;
   
    while ("i".equalsIgnoreCase("e"))
    {
        try
        {
            inputLine = in.readLine();
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (inputLine.length() != 0)
        {
          try
        {
            tOut.sendText(inputLine);
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        }
    }
   

}
}
[/pre]


The only problem Eclipse is telling me about is that private static String inputLine = null; should not end in a ;. but it should be a {?


Help!
#24
Excuse my Java newb-ey-ness, but what characters are sent after every string, and what characters does readline look for, and are the two the same?

If I tell your socket to write out "test" will it send "test" + ASCII 13, "test" + ASCIII 10, "test" + ASCII 13 + ASCII 10, or something completely different?
#25
Botdev / Re: New Feature
October 14, 2005, 11:36:05 AM
Hmm.. Using Starcraft's built in print function is a tad more complicated then it looks, not to mention it would not be cross platform.

I got my idea to work:

Basicly, you hit F8 to toggle on and off.

When on, a  small box appears with a list of channels on the left, and the chat on the right. When you click on a channel on the left (or type one in) the bot joins that channel and begins to add the text to that window.

If you don't have F keys, its command/control + 8.

It works great.. I use it. Should be in the first beta release of my bot: http://luxer.cjb.net
#26
General Programming / [Java] Sockets in a JavaOp Plugin
October 11, 2005, 11:06:24 AM
I am having some problems with Java sockets... Buffering incoming data.

Here is the code for my JavaOp plugin:


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Properties;

import javax.swing.JComponent;

import callback_interfaces.PluginCallbackRegister;
import callback_interfaces.PublicExposedFunctions;
import callback_interfaces.StaticExposedFunctions;
import exceptions.PluginException;
import plugin_interfaces.ConnectionCallback;
import plugin_interfaces.EventCallback;
import plugin_interfaces.GenericPluginInterface;

public class PluginMain extends GenericPluginInterface implements EventCallback, ConnectionCallback
{

    private static ServerSocket serverSocket = null;

    private static Socket clientSocket = null;

    private static PrintWriter pOut = null;

    private static BufferedReader in = null;
    private static PublicExposedFunctions tOut = null;

    public void load(StaticExposedFunctions staticFuncs)
    {
       
    }

public void activate(PublicExposedFunctions out, PluginCallbackRegister register)
    {
    register.registerEventPlugin(this, null);
    register.registerConnectionPlugin(this, null);
    tOut = out;
    }
public void deactivate(PluginCallbackRegister register)
    {
        // TODO Auto-generated method stub

    }

    public String getName()
    {
        // TODO Auto-generated method stub
        return "SBCP";
    }

    public String getVersion()
    {
        // TODO Auto-generated method stub
        return "1.0";
    }

    public String getAuthorName()
    {
        // TODO Auto-generated method stub
        return "Ryan Marcus";
    }

    public String getAuthorWebsite()
    {
        // TODO Auto-generated method stub
        return "None";
    }

    public String getAuthorEmail()
    {
        // TODO Auto-generated method stub
        return "ryan@marcusfamily.info";
    }

    public String getLongDescription()
    {
        // TODO Auto-generated method stub
        return "Allows you to connect with SBCP";
    }

    public Properties getDefaultSettingValues()
    {
        // TODO Auto-generated method stub
        Properties p = new Properties();
        return p;
    }

    public Properties getSettingsDescription()
    {
        // TODO Auto-generated method stub
        Properties p = new Properties();
        return p;
    }

    public JComponent getComponent(String settingName, String value)
    {
        // TODO Auto-generated method stub
        return null;
    }

    public Properties getGlobalDefaultSettingValues()
    {
        // TODO Auto-generated method stub
        Properties p = new Properties();
        return p;
    }

    public Properties getGlobalSettingsDescription()
    {
        // TODO Auto-generated method stub
        Properties p = new Properties();
        return p;
    }

    public JComponent getGlobalComponent(String settingName, String value)
    {
        // TODO Auto-generated method stub
        return null;
    }
   
   
    public void talk(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
       pOut.println("TALK" + user + " " + statstring);
    }

    public void emote(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("EMOT" + user + " " + statstring);
    }

    public void whisperFrom(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("WSFM" + user + " " + statstring);
    }

    public void whisperTo(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("WSCN" + user + " " + statstring);
    }

    public void userShow(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("USIN" + user + " " + statstring);
    }

    public void userJoin(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("USJN" + user + " " + statstring);
    }

    public void userLeave(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("USLV" + user + " " + statstring);
    }

    public void userFlags(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("USFG" + user + " " + statstring);
    }

    public void error(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("ERRO" + user + " " + statstring);
    }

    public void info(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("INFO" + user + " " + statstring);
    }

    public void broadcast(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("BRDC" + user + " " + statstring);
    }

    public void channel(String user, String statstring, int ping, int flags) throws IOException, PluginException
    {
        pOut.println("CHAN" + user + " " + statstring);
    }
   
    public final boolean ABORT = false;
    public final boolean CONTINUE = true;
   
    /** The bot is about to connect to a server, but hasn't yet.  At this point, the connection can be stopped. */
    public boolean connecting(String host, int port, Object data) throws IOException, PluginException
    {
        return false;
    }
    /** The bot has just connected to the server. */
    public void connected(String host, int port, Object data) throws IOException, PluginException
    {
       
       
       
        try {
            serverSocket = new ServerSocket(4444);
        } catch (IOException e) {
            System.err.println("Could not listen on port: 4444.");
            System.exit(1);
        }

   
        try
        {
            clientSocket = serverSocket.accept();
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
     

       
         
         
         try
        {
            pOut = new PrintWriter(clientSocket.getOutputStream(), true);
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
       
       
     
           
            try
            {
                in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
            }
            catch (IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
       
        pOut.println("Connected!");
       
        String inputLine = null;
        while ("i".equalsIgnoreCase("a"))
        {
            try
            {
                inputLine = in.readLine();
            }
            catch (IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (inputLine.length() != 0)
            {
              try
            {
                tOut.sendText(inputLine);
            }
            catch (IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            }
        }
           
    }
   
    /** The bot is about to disconnect from the server.  This is only called for planned disconnects. */
    public boolean disconnecting(Object data)
    {
        return false;
    }
    /** The bot has disconnected from the server. */
    public void disconnected(Object data)
    {
    }


}


Ya, it sucks. So what?

How should I handle incoming data? How should I parse it? Are there already functions to split data at line breaks?
#27
Botdev / Re: New Feature
October 09, 2005, 06:36:52 PM
Hmmm.. Intersting idea.

Same could apply if you wanted to be in multiple channels at once... A channel per bot.

It might be more practicle to set a hotkey to tell a third party program to show a popup above the game / other channel with an entry spot...

Added to my todo list for my bot.
#28
Entertainment District / Re: Our President can't talk!
October 05, 2005, 08:04:48 AM
Yes, its from the Daily Show.

Did you really believe "Speacholigst"?
#30
Ok, so just to make sure:

Mac: chr(13)
Linux: chr(10)
PC: chr(13) + chr(10)

Right?