Package com.uwyn.drone.protocol.commands

Examples of com.uwyn.drone.protocol.commands.Privmsg


   
    try
    {
      synchronized (mServer)
      {
        mServer.send(new Privmsg(mName, message));
      }
    }
    catch (CoreException e)
    {
      throw new ChannelMessageErrorException(this, message, e);
View Full Code Here


    if (command.equals("do"))
    {
      if (null == arguments ||
        0 == arguments.length())
      {
        bot.send(new Privmsg(nick, "You need to provide an argument to the command."));
        return;
      }
     
      Matcher seen_matcher = DO_PATTERN.matcher(arguments);
     
      if (!seen_matcher.matches() ||
        seen_matcher.groupCount() != 2)
      {
        bot.send(new Privmsg(nick, "Invalid syntax '" + command + " " + arguments + "'"));
        return;
      }
     
      // obtain the requested channel
      String channel_name = seen_matcher.group(1).toLowerCase();
View Full Code Here

        String  name = arguments.trim();
        FaqData  faq_data = database_faq.getFaq(bot, name);
       
        if (faq_data != null)
        {
          bot.send(new Privmsg(nick, faq_data.getName()+": "+(faq_data.isRandom() ? "random" : "not random")+": "+faq_data.getAnswer()));
        }
        else
        {
          bot.send(new Privmsg(nick, "Faq '"+name+"' couldn't be found."));
        }
      }
      else if (command.equals("randfaq"))
      {
        FaqData  faq_data = database_faq.getRandomFaq(bot);
       
        if (faq_data != null)
        {
          bot.send(new Privmsg(nick, faq_data.getName()+": "+faq_data.getAnswer()));
        }
        else
        {
          bot.send(new Privmsg(nick, "No random faq could be found."));
        }
      }
      else if (command.equals("randfaqon"))
      {
        String  name = arguments.trim();
        if (database_faq.setRandom(bot, name, true))
        {
          bot.send(new Privmsg(nick, "Random retrieval has been enabled for faq '"+name+"'."));
        }
        else
        {
          bot.send(new Privmsg(nick, "Faq '"+name+"' couldn't be found."));
        }
      }
      else if (command.equals("randfaqoff"))
      {
        String  name = arguments.trim();
        if (database_faq.setRandom(bot, name, false))
        {
          bot.send(new Privmsg(nick, "Random retrieval has been disabled for faq '"+name+"'."));
        }
        else
        {
          bot.send(new Privmsg(nick, "Faq '"+name+"' couldn't be found."));
        }
      }
      else if (command.equals("addfaq"))
      {
        int  first_colon_index = arguments.indexOf(":");
        if (-1 == first_colon_index)
        {
          bot.send(new Privmsg(nick, "Invalid syntax '!"+command+" "+arguments+"'"));
          return;
        }
        else
        {
          int  second_colon_index = arguments.indexOf(":", first_colon_index+1);
         
          String  name = null;
          String  answer = null;
          boolean  random = false;
         
          if (second_colon_index != -1)
          {
            String random_string = arguments.substring(first_colon_index+1, second_colon_index).trim();
            if (1 == random_string.length())
            {
              if ('1' == random_string.charAt(0))
              {
                random = true;
                answer = arguments.substring(second_colon_index+1).trim();
              }
              else if ('0' == random_string.charAt(0))
              {
                random = false;
                answer = arguments.substring(second_colon_index+1).trim();
              }
              else
              {
                bot.send(new Privmsg(nick, "Invalid syntax '!"+command+" "+arguments+"'"));
                return;
              }
            }
          }
         
          name = arguments.substring(0, first_colon_index).trim();
          if (null == answer)
          {
            answer = arguments.substring(first_colon_index+1).trim();
          }
         
          try
          {
            FaqData  faq_data = new FaqData(name, answer);
            faq_data.setRandom(random);
            database_faq.addFaq(bot, faq_data);
            bot.send(new Privmsg(nick, "Added faq '"+name+"'"));
          }
          catch (FaqManagerException e)
          {
            try
            {
              if (database_faq.getFaq(bot, name) != null)
              {
                bot.send(new Privmsg(nick, "Faq '"+name+"' already exists, delete it first to update it."));
              }
            }
            catch (FaqManagerException e2)
            {
              e.fillInStackTrace();
              throw e;
            }
          }
        }
      }
      else if (command.equals("delfaq"))
      {
        String  name = arguments.trim();

        if (database_faq.removeFaq(bot, arguments))
        {
          bot.send(new Privmsg(nick, "Removed faq '"+name+"'"));
        }
        else
        {
          bot.send(new Privmsg(nick, "Faq '"+name+"' couldn't be found."));
        }
      }
      else if (command.equals("editfaq"))
      {
        int  first_colon_index = arguments.indexOf(":");
        if (-1 == first_colon_index)
        {
          bot.send(new Privmsg(nick, "Invalid syntax '!"+command+" "+arguments+"'"));
          return;
        }
        else
        {
          String  name = null;
          String  answer = null;
         
          name = arguments.substring(0, first_colon_index).trim();
          answer = arguments.substring(first_colon_index+1).trim();
         
          FaqData  faq_data = database_faq.getFaq(bot, name);
          if (null == faq_data)
          {
            bot.send(new Privmsg(nick, "Faq '"+name+"' doesn't exist."));
          }
          else
          {
            faq_data.setName(name);
            faq_data.setAnswer(answer);
            if (database_faq.editFaq(faq_data))
            {
              bot.send(new Privmsg(nick, "Edited faq '"+name+"'"));
            }
            else
            {
              bot.send(new Privmsg(nick, "Error while editing faq '"+name+"'"));
            }
          }
        }
      }
    }
View Full Code Here

 
  public void loggedon(Bot bot)
  throws CoreException
  {
    bot.suspendLogon();
    bot.send(new Privmsg(mNick, "identify "+mPassword));
  }
View Full Code Here

    if (command.equals("say"))
    {
      if (null == arguments ||
        0 == arguments.length())
      {
        bot.send(new Privmsg(nick, "You need to provide an argument to the command."));
        return;
      }
     
      Matcher seen_matcher = SAY_PATTERN.matcher(arguments);
     
      if (!seen_matcher.matches() ||
        seen_matcher.groupCount() != 2)
      {
        bot.send(new Privmsg(nick, "Invalid syntax '"+command+" "+arguments+"'"));
        return;
      }
     
      // obtain the requested channel
      String channel_name = seen_matcher.group(1).toLowerCase();
View Full Code Here

      if (command.equals("logsearch"))
      {
        if (null == arguments ||
           0 == arguments.length())
        {
          bot.send(new Privmsg(nick, "You need to provide a search argument."));
          return;
        }

        Matcher logsearch_matcher = SEARCH_PATTERN.matcher(arguments);

        if (!logsearch_matcher.matches() ||
          logsearch_matcher.groupCount() != 2)
        {
          bot.send(new Privmsg(nick, "Invalid syntax '"+command+" "+arguments+"'"));
          return;
        }

        // obtain the requested channel
        String channel_name = logsearch_matcher.group(1);
        String search = logsearch_matcher.group(2);
        Channel  channel = bot.getServer().getChannel(channel_name);
        if (null == channel)
        {
          bot.send(new Privmsg(nick, "Unknown channel '"+channel_name+"'"));
          return;
        }

        SearchResults  search_results = new SearchResults(bot, nick);
        try
        {
          if (!database_log.searchLog(search_results, bot, channel, search))
          {
            bot.send(new Privmsg(nick, "No results for '"+search+"' could be found in channel '"+channel_name+"'."));
          }
        }
        catch (InvalidSearchSyntaxException e)
        {
          bot.send(new Privmsg(nick, "The search syntax of '"+search+"' is not valid, it should be like this :"));
          bot.send(new Privmsg(nick, SEARCH_SYNTAX));
        }
      }
    }
    catch (LogManagerException e)
    {
View Full Code Here

          else
          {
            formatted_result.append(serverMessage.getTrailing());
          }

          mBot.send(new Privmsg(mNick, formatted_result.toString()));

          return true;
        }
        else
        {
          mBot.send(new Privmsg(mNick, "!!! more than "+MAX_RESULTS+" matches, refine your search."));
        }
      }
      catch (CoreException e)
      {
        Logger.getLogger("com.uwyn.drone.modules").severe(ExceptionUtils.getExceptionStackTrace(e));
View Full Code Here

    if (command.equals("seen"))
    {
      if (null == arguments ||
        0 == arguments.length())
      {
        bot.send(new Privmsg(nick, "You need to provide an argument to the command."));
        return;
      }
     
      Matcher seen_matcher = SEEN_PATTERN.matcher(arguments.toLowerCase());
     
      if (!seen_matcher.matches() ||
        seen_matcher.groupCount() != 2)
      {
        bot.send(new Privmsg(nick, "Invalid syntax '"+command+" "+arguments+"'"));
        return;
      }
     
      // obtain the requested channel
      String channel_name = seen_matcher.group(1);
View Full Code Here

            if (reply != null)
            {
              Iterator  nicks_it = message_seen.getNicks().iterator();
              while (nicks_it.hasNext())
              {
                bot.send(new Privmsg((String)nicks_it.next(), reply));
              }
            }
          }
        }
      }
View Full Code Here

    if (command.equals("register"))
    {
      if (null == arguments ||
        arguments.length() < 2)
      {
        bot.send(new Privmsg(nick, "You need to provide 2 arguments to the command."));
        return;
      }
     
      Matcher register_matcher = REGISTER_PATTERN.matcher(arguments);
     
      if (!register_matcher.matches() ||
        register_matcher.groupCount() != 2)
      {
        bot.send(new Privmsg(nick, "Invalid syntax '"+command+" "+arguments+"'"));
        return;
      }
     
      String botnick = register_matcher.group(1).toLowerCase();
      String password = register_matcher.group(2);
      bot.send(new Privmsg(botnick, "register "+password));
    }
  }
View Full Code Here

TOP

Related Classes of com.uwyn.drone.protocol.commands.Privmsg

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.