Ejemplo n.º 1
0
void ServerEvents::OnMutelistItem( const wxString& /*unused*/, const wxString& mutee, const wxString& description )
{
    wxString message = mutee;
    wxString desc = description;
    wxString mutetime = GetWordParam( desc );
		long time;
		if ( mutetime == _T("indefinite") ) message << _(" indefinite time remaining");
		else if ( mutetime.ToLong(&time) ) message << wxString::Format( _(" %d minutes remaining"), time/60 + 1 );
		else message << mutetime;
		if ( !desc.IsEmpty() )  message << _T(", ") << desc;
    mutelistWindow( message );
}
Ejemplo n.º 2
0
bool ReadError(uint8_t dxl_id, uint8_t* error_return) {
    uint8_t data[MAX_PACKET_BYTES];

    int position_register = 50;
    int position_bytes = 1;
    int num_parameters_tx = MakeReadPacket(data, dxl_id, position_register, position_bytes);

    uint16_t num_parameters_rx = 1 + position_bytes; // Error, Position low, position high
    bool result = TXRXPacket(data, num_parameters_tx, num_parameters_rx);

    uint8_t error = GetByteParam(data, 0);
    if (result && error == 0) {
        *error_return = GetWordParam(data, 1);
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 3
0
bool SendPing(uint8_t dxl_id, int* modelnum, int* firmware_version) {
    uint8_t data[MAX_PACKET_BYTES];

    // Make packet.
    uint16_t num_parameters_tx = MakePingPacket(data, dxl_id);

    uint16_t num_parameters_rx = 4; // Error, model low, model high, firmware
    bool result = TXRXPacket(data, num_parameters_tx, num_parameters_rx);

    uint8_t error = GetByteParam(data, 0);
    if (result && error == 0) {
        *modelnum = GetWordParam(data, 1);
        *firmware_version = GetByteParam(data, 3);
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 4
0
bool Channel::ExecuteSayCommand( const wxString& in )
{
  if ( in.length() == 0 ) return true;

  if ( in[0] != '/' ) return false;

  wxString subcmd = in.BeforeFirst(' ').Lower();
  wxString params = in.AfterFirst( ' ' );

  wxString cmdline = in;
  wxString param = GetWordParam( cmdline );
  if ( param == _T("/me") ) {
    DoAction( cmdline );
    return true;
  } else if ( in == _T("/part") || in == _T("/p") ) {
    Leave();
    uidata.panel = 0;
    return true;
  } else if ( param == _T("/sayver") ) {
	  //!this instance is not replaced with GetAppname for sake of help/debug online
    DoAction( _T("is using SpringLobby v") + GetSpringLobbyVersion() );
    return true;
  } else if(subcmd==_T("/userban")){
    m_banned_users.insert(params);
    m_serv.SayPrivate(_T("ChanServ"),_T("!kick #")+GetName()+_T(" ")+params);
    return true;
  } else if(subcmd==_T("/userunban")){
    m_banned_users.erase(params);
    return true;
  } else if(subcmd==_T("/banregex")){
    ui().OnChannelMessage(m_name,_T("/banregex ")+params);
    m_do_ban_regex=!params.empty();
    if(m_do_ban_regex){
      #ifdef wxHAS_REGEX_ADVANCED
      m_ban_regex.Compile(params, wxRE_ADVANCED);
      #else
      m_ban_regex.Compile(params, wxRE_EXTENDED);
      #endif
      if(!m_ban_regex.IsValid())ui().OnChannelMessage(m_name,_T("Invalid regular expression"));
    }
    return true;
  } else if(subcmd==_T("/unbanregex")){
    ui().OnChannelMessage(m_name,_T("/unbanregex ")+params);
    m_do_unban_regex=!params.empty();
    if(m_do_unban_regex){
      #ifdef wxHAS_REGEX_ADVANCED
      m_unban_regex.Compile(params, wxRE_ADVANCED);
      #else
      m_unban_regex.Compile(params, wxRE_EXTENDED);
      #endif
      if(!m_unban_regex.IsValid())ui().OnChannelMessage(m_name,_T("Invalid regular expression"));
    }
    return true;
  } else if (subcmd==_T("/checkban")) {
    if(IsBanned(params)){
      ui().OnChannelMessage(m_name,params+_T(" is banned"));
    }else{
      ui().OnChannelMessage(m_name,params+_T(" is not banned"));
    }
    return true;
  }


  else if(subcmd==_T("/banregexmsg")){
    ui().OnChannelMessage(m_name,_T("/banregexmsg ")+params);
    m_ban_regex_msg=params;
    return true;
  }

  return false;
}