Package com.uwyn.drone.core

Examples of com.uwyn.drone.core.Bot


    }
    else
    {
      botname = getInput("botname");
    }
    Bot bot = Home.validateBotName(errors, botname);
   
    // act according to the actions that were performed
    if (errors.size() > 0)
    {
      if (botname != null)
      {
        t.setValue("botname", encodeHtml(botname));
      }
      validation_builder.generateValidationErrors(t, errors, null, null);
      validation_builder.generateErrorMarkings(t, errors, null, null);
    }
    else
    {
      if (hasSubmission("perform_change"))
      {
        String new_nick = getParameter("new_nick");
       
        t.setValue("botname", encodeHtml(bot.getName()));
        t.setValue("nick", encodeHtml(new_nick));

        try
        {
          bot.addBotListener(this);
          bot.changeNick(new_nick);
          synchronized (this)
          {
            if (null == bot.getConnectedNick() ||
              !bot.getConnectedNick().equals(new_nick))
            {
              try
              {
                this.wait();
              }
              catch (InterruptedException e)
              {
                // do nothing
              }
            }
          }
          bot.removeBotListener(this);
         
          if (bot.getConnectedNick().equals(new_nick))
          {
            exit("nick_changed");
          }
          validation_builder.setFallbackErrorArea(t, t.getBlock("ERROR_CHANGING_NICK"));
        }
View Full Code Here


  {
    ValidationBuilderXhtml builder = new ValidationBuilderXhtml();
   
    ArrayList  errors = new ArrayList();
    String    botname = getParameter("bot_to_pause");
    Bot      bot = Home.validateBotName(errors, botname);
    if (null == bot)
    {
      if (botname != null)
      {
        mTemplate.setValue("botname", encodeHtml(botname));
      }
      builder.generateValidationErrors(mTemplate, errors, null, null);
      processElement();
      return;
    }
   
    try
    {
      bot.pause();
    }
    catch (CoreException e)
    {
      builder.setFallbackErrorArea(mTemplate, "Error while pausing the bot '"+encodeHtml(bot.getName())+"' : "+ExceptionUtils.getExceptionStackTrace(e));
    }
   
    processElement();
  }
View Full Code Here

  {
    ValidationBuilderXhtml builder = new ValidationBuilderXhtml();
   
    ArrayList  errors = new ArrayList();
    String    botname = getParameter("bot_to_resume");
    Bot      bot = Home.validateBotName(errors, botname);
    if (null == bot)
    {
      if (botname != null)
      {
        mTemplate.setValue("botname", encodeHtml(botname));
      }
      builder.generateValidationErrors(mTemplate, errors, null, null);
      processElement();
      return;
    }

    try
    {
      bot.resume();
    }
    catch (CoreException e)
    {
      builder.setFallbackErrorArea(mTemplate, "Error while resuming the bot '"+encodeHtml(bot.getName())+"' : "+ExceptionUtils.getExceptionStackTrace(e));
    }
   
    processElement();
  }
View Full Code Here

  {
    ValidationBuilderXhtml builder = new ValidationBuilderXhtml();
   
    ArrayList  errors = new ArrayList();
    String    botname = getParameter("bot_to_reconnect");
    Bot      bot = Home.validateBotName(errors, botname);
    if (null == bot)
    {
      if (botname != null)
      {
        mTemplate.setValue("botname", encodeHtml(botname));
      }
      builder.generateValidationErrors(mTemplate, errors, null, null);
      processElement();
      return;
    }

    try
    {
      bot.addBotListener(this);
      synchronized (this)
      {
        bot.redoLogon();
       
        try
        {
          this.wait();
        }
        catch (InterruptedException e)
        {
          // do nothing
        }
      }
      bot.removeBotListener(this);
    }
    catch (CoreException e)
    {
      builder.setFallbackErrorArea(mTemplate, "Error while reconnecting the bot '"+encodeHtml(bot.getName())+"' : "+ExceptionUtils.getExceptionStackTrace(e));
    }
    processElement();
  }
View Full Code Here

 
  private void generateBotsList()
  {
    Collection  bots = ((BotsRunner)Rep.getParticipant("com.uwyn.drone.core.DroneParticipant").getObject()).getBots();
    Iterator  bots_it = bots.iterator();
    Bot      bot = null;
    while (bots_it.hasNext())
    {
      bot = (Bot)bots_it.next();
      mTemplate.setValue("botname", encodeHtml(bot.getName()));
      mTemplate.setValue("connected_nick", encodeHtml(bot.getConnectedNick()));
      mTemplate.setValue("nicks", encodeHtml(bot.getNick()+", "+bot.getAltNick()));
      if (bot.isPaused())
      {
        setSubmissionForm(mTemplate, "resume", new String[] {"bot_to_resume", bot.getName()});
        mTemplate.setBlock("actions", "action_resume");
      }
      else
      {
        setSubmissionForm(mTemplate, "pause", new String[] {"bot_to_pause", bot.getName()});
        mTemplate.setBlock("actions", "action_pause");
      }
      setExitForm(mTemplate, "change_nick", new String[] {"botname", bot.getName()});
      setSubmissionForm(mTemplate, "reconnect", new String[] {"bot_to_reconnect", bot.getName()});
      mTemplate.appendBlock("actions", "action_reconnect");
      mTemplate.appendBlock("actions", "action_changenick");
     
      mTemplate.appendBlock("bots", "bot");
    }
View Full Code Here

  }
 
  public void run()
  {
    Iterator  bots_it = null;
    Bot      bot = null;
    try
    {
      bots_it = mBots.iterator();
      while (bots_it.hasNext())
      {
        bot = (Bot)bots_it.next();
       
        bot.addBotListener(this);
        bot.logon();

        // wait for bot startup
        if (null == mBotError &&
          !bot.isLoggedOn())
        {
          try
          {
            synchronized (mBotsMonitor)
            {
              mBotsMonitor.wait();
            }
          }
          catch (InterruptedException e)
          {
            // do nothing, just let other threads execute
            Thread.yield();
          }
        }
      }
     
     
      // wait for bot termination
      while (areBotsLoggedOn() &&
           !isInterrupted())
      {
        try
        {
          synchronized (mBotsMonitor)
          {
            mBotsMonitor.wait();
          }
        }
        catch (InterruptedException e)
        {
          break;
        }
      }
     
      // disconnect the bots
      bots_it = mBots.iterator();
      while (bots_it.hasNext())
      {
        bot = (Bot)bots_it.next();
        bot.disconnect();
      }
     
      fireFinished();
    }
    catch (CoreException e)
View Full Code Here

    String  bot_name = null;
    try
    {
      bot_name = task.getTaskoptionValue("bot");
     
      Bot bot = BotFactory.get(bot_name);
      if (bot != null)
      {
        DatabaseFaqs  database_faq = DatabaseFaqsFactory.get();
        FaqData      faq_data = database_faq.getRandomFaq(bot);
        if (faq_data != null)
        {
          Iterator  channels_it = bot.getJoinedChannels().iterator();
          Channel    channel = null;
          while (channels_it.hasNext())
          {
            channel = (Channel)channels_it.next();
            channel.send(faq_data.getName()+": "+faq_data.getAnswer());
View Full Code Here

  public final void processElement()
  {
    ArrayList errors = new ArrayList();

    Bot      bot = null;
    Channel    channel = null;
    Calendar  day = null;

    String botname = null;
    String channelname = null;
View Full Code Here

        Iterator   iter = bots.iterator();

        String readerDir = null;
        while (iter.hasNext())
        {
          Bot bot = (Bot)iter.next();

          if (bot.getName().equals(getInput("botname")))
          {
            StringBuffer key = new StringBuffer();
            key
              .append(Config.getRepInstance().getString("LUCENE_DIR"))
              .append(File.separator)
              .append(bot.getName())
              .append("-")
              .append(bot.getServer().getServerName())
              .append("-")
              .append(getInput("channelname").substring(1));

            readerDir = key.toString();
          }
View Full Code Here

 
  public void processElement()
  {
    Collection  bots = BotsRunner.getRepInstance().getBots();
    Iterator  bots_it = bots.iterator();
    Bot      bot = null;
    while (bots_it.hasNext())
    {
      bot = (Bot)bots_it.next();
     
      mTemplate.setValue("bot", encodeHtml(bot.getName()));
      mTemplate.appendBlock("options", "option");
    }

    print(mTemplate);
  }
View Full Code Here

TOP

Related Classes of com.uwyn.drone.core.Bot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.